Track robot pig identification method based on weak network condition

By combining a tracked robot with a gridded map and perspective transformation, the latency and stability issues of pig identification in weak network environments were solved, enabling real-time, high-precision pig counting in remote areas and adapting to pig identification in different scenarios.

CN121214501APending Publication Date: 2025-12-26ELINKS SCI & TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511771962.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

Existing pig identification technologies suffer from severe latency and poor stability in weak network environments, are unable to output counting results in real time, and have poor adaptability to occlusion and posture changes. In particular, they cannot meet the bandwidth requirements of cloud AI processing when network conditions are poor in remote areas.

Method used

A tracked robot carrying a computing module and a fisheye camera is used to correct image distortion through rasterized maps and perspective transformation, identify pigs in real time and calculate their actual area. A local AI model is used to identify the pig's bounding box and segmentation mask, and overlapping area processing is combined to avoid double counting.

Benefits of technology

It achieves stable, real-time pig identification and high-precision counting in weak network environments, has strong anti-occlusion capabilities, adapts to different pen shapes and pig posture changes, and provides efficient counting results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121214501A_ABST
    Figure CN121214501A_ABST
Patent Text Reader

Abstract

The invention discloses a rail robot pig identification method based on a weak network condition, and relates to the technical field of pig identification, and the method comprises the steps: building a rasterized map for a pig house, and building a mapping relation from an image pixel coordinate to a ground world coordinate; distortion correction is carried out on an image collected in the advancing process of a rail robot above the pig house, pigs are recognized, and a bounding box and a segmentation mask of each pig are obtained; calculating the number of pixels based on the segmentation mask, and performing perspective transformation to obtain a real area; when front and back frames collected when the rail robot crosses over the overlapping area belong to different grids respectively, judging whether the same pig is the same pig or not by analyzing the area change of the same pig in the front and back frames; and updating pig calculation according to an overlapping region matching result, and outputting a total recognition number. The method performs offline calculation, does not depend on a network, and works stably in a weak network environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of pig identification technology, and more specifically to a method for identifying pigs using a tracked robot under weak network conditions. Background Technology

[0002] In large-scale pig farms, accurately counting the pigs in each pen regularly is a crucial aspect of pig farming management. Traditional methods mainly rely on manual visual counting, which is inefficient and prone to errors due to pig movement, obstruction, and other factors. With the development of computer vision technology, automatic counting methods based on video surveillance are gradually being applied.

[0003] However, existing technical solutions have the following technical problems: most solutions use cloud-based AI processing, which requires transmitting high-definition video streams to cloud servers. In weak network environments, the latency is severe (2-5 seconds), and the stability is poor. Due to changes in camera angle and distance, the size of the pigs in the image changes, which can easily lead to double counting or undercounting. When network conditions are poor, image transmission delays prevent the real-time output of counting results. The solutions also have poor adaptability to scenarios such as pig occlusion, changes in lighting, and changes in posture.

[0004] Especially in farms in remote areas, the network infrastructure is poor and cannot meet the bandwidth requirements for cloud AI processing. Summary of the Invention

[0005] This invention provides a method for identifying pigs on a track-mounted robot under weak network conditions, which solves the problems of existing technologies.

[0006] In a first aspect, the present invention provides a method for identifying pigs using a tracked robot under weak network conditions, comprising the following steps: A rasterized map of the pigsty was created, and a mapping relationship from image pixel coordinates to ground world coordinates was established. Distortion correction is used to collect images of a robot traveling on a track above the pigsty, identify pigs, and obtain the bounding box and segmentation mask for each pig. The number of pixels is calculated based on the segmentation mask, and the perspective transformation is used to obtain the true area. When the track robot moves across the overlapping area, the frames collected before and after belong to different grids. By analyzing the area change of the same pig in the frames before and after, it can be determined whether it is the same pig. Update the pig count based on the overlapping region matching results and output the total number of pigs identified.

[0007] Furthermore, the process of creating a rasterized map of the pigsty and establishing a mapping relationship from image pixel coordinates to ground world coordinates specifically includes: Initialization process: Load the AI ​​model and grid map from the computing module on the orbital robot, and initialize the camera parameters; Obtain the camera intrinsic parameter matrix K and distortion coefficients. Based on the installation height and angle, determine the camera's extrinsic parameters relative to the ground, including the rotation matrix R and translation vector t. Establish the perspective transformation matrix. Based on the intrinsic and extrinsic parameters, establish the mapping relationship from image pixel coordinates to ground coordinates. The data to be entered is: pigpen length is L, width is W, and grid size is a×a; Number of grid cells: number of rows = ceil(L / a), number of columns = ceil(W / a); The overlap ratio of adjacent grid cells is set to r, and the overlap width is a*r.

[0008] Furthermore, the distortion correction process involves capturing images from the orbiting robot above the pigsty, identifying pigs, and obtaining the bounding box and segmentation mask for each pig. Specifically, this includes: The distortion coefficients calibrated by the camera on the track robot are used to perform algorithmic correction of the fisheye camera images through OpenCV in the AI ​​model mounted on the track robot, including contrast enhancement and histogram equalization. The image is input into the instance segmentation model such as YOLOv8-Instance carried by the track robot, which outputs the bounding box (x1, y1, x2, y2), confidence score, category and segmentation mask for each detected pig, and filters out detection results with a confidence score lower than the threshold of 0.5.

[0009] Furthermore, the step of calculating the number of pixels based on the segmentation mask and transforming the perspective into the true area includes: For each detected pig, the pixel area, i.e. the number of pixels, is calculated using its segmentation mask; By using perspective transformation, the pixel area is converted into the real-world area; Specifically: Find the lowest point of the pig mask, which is the point where the pig touches the ground, and take that point as the pig's ground position. Using camera parameters and the ground plane equation, calculate the real-world coordinates corresponding to this ground location; Calculate the ground area corresponding to each pixel, and then multiply it by the pixel area to get the actual area; The formula is as follows: Let the equation of the ground plane be Z = 0. Then the relationship between a point (X, Y, 0) in the world coordinate system and the image pixel coordinates (u, v) is: Where H is the homography matrix, H = K[r1 r2 t], where r1 and r2 are the first two columns of the rotation matrix R; since the area is calculated, it can be corrected by calculating the size of the ground region corresponding to a pixel in the image. Specifically, for each pixel of the pig mask, the ground area (a micro-element) corresponding to that pixel can be calculated, and then integrated to obtain the true area of ​​the entire pig. However, this method is computationally intensive. Therefore, the bounding box of the pig mask is calculated first, and two points on the bottom edge of the bounding box are taken to calculate the ground distance between these two points, thus obtaining the proportion in the width direction. Similarly, two points are taken in the height direction to calculate the ground distance. Then, the area is approximated based on the pixel area and the ground area corresponding to each pixel; In this invention, since the ground in the pigsty is flat and the height of the pigs is negligible relative to the camera height, we can use the bottom area of ​​the pig mask to estimate the actual area. Specific steps: Find the bottom center point P(u, v) of the pig mask; Calculate the ground coordinates (X, Y) corresponding to point P; Calculate the ground displacement (dX, dY) corresponding to a tiny pixel displacement (du, dv) near point P; The ground area corresponding to one pixel at this pixel location is approximately |dX * dY|. Because the pigs are not laid flat on the ground but have height, this method underestimates the actual area. Therefore, a correction factor should be added based on prior experiments, or the average height should be used for correction. Specifically: The actual area = pixel area * (ground unit pixel area), where the ground unit pixel area is calculated using the bottom center point of the pig mask: unit pixel area = (ΔX * ΔY), where ΔX and ΔY are the horizontal and vertical ground distances of the pixel, respectively. Calculate ΔX and ΔY: At point P(u, v), calculate: [ X 1, Y 1,1] T = s 1∗ H −1[ u , v ,1] T [ X 2, Y 2,1] T = s 2∗ H −1[ u +1, v ,1] T Where ΔX = |X2 - X1|, similarly calculate ΔY in the vertical direction. Due to perspective transformation, the area per unit pixel is different at different positions, so it needs to be calculated separately for each pig.

[0010] Furthermore, when the orbital robot crosses the overlapping area, the preceding and following frames belong to different grids. The determination of whether it is the same pig is made by analyzing the area change of the same pig in the preceding and following frames. Specifically, this includes: The robot moves in the x-direction, and the overlapping area is the overlapping part of two adjacent grids A and B; When the robot enters the overlapping area, it records the pig data in the overlapping area (the current frame belonging to grid A and the next frame belonging to grid B). For each pig in grid A, find a matching pig in grid B, with the following matching criteria: In the ground coordinates after perspective transformation, the distance between the two pigs is less than the threshold. The area changes of the two pigs are within a certain threshold range. Due to the robot's movement, the distance between the camera and the pigs changes, and the area will change accordingly. According to perspective transformation, the farther away from the camera, the smaller the area. Therefore, from grid A to grid B, if the pig passes under the camera, the distance first decreases and then increases, and the area first increases and then decreases. However, since our robot moves from grid A to grid B, for the same pig, the area in grid A and grid B should follow a certain pattern of change. The specific area change rule is as follows: the height of the robot camera is H, the horizontal distance from the pig to the bottom of the camera is d, then the distance from the camera to the pig is sqrt(d^2 + H^2), and the area is proportional to 1 / (d^2 + H^2). Therefore, the matching algorithm is as follows: For pig i in grid A, calculate its ground coordinates P_i; for pig j in grid B, calculate its ground coordinates P_j. Calculate the distance difference: Δd = |P_i - P_j|. If Δd < a threshold (e.g., 0.3 meters), it is considered the same pig. Simultaneously, calculate the area ratio: R = S_A / S_B, theoretically (d_B^2 + H^2) / (d_A^2 + H^2). If the error between the actual area ratio and the theoretical area ratio is within the allowable range (e.g., 20%), a match is confirmed. If the match is successful, it is considered the same pig and not counted repeatedly. Otherwise, count them separately.

[0011] Furthermore, the preceding and following frames specifically include: Furthermore, the step of updating the pig count based on the overlapping region matching results and outputting the total number of identified pigs specifically includes: The initial count is 0. For each grid, the unique ID of the pigs that have been counted is recorded. When processing a new grid, only pigs that have not appeared in the previous grid are counted. After the track robot travels to the end of a pig pen, the total number of pigs identified is accumulated and output, which is recorded as the total number of pigs in the current pig pen.

[0012] The method for pig identification on a tracked robot under weak network conditions provided by this invention achieves the following technical effects: Offline computing: It does not rely on the network and works stably in weak network environments; Real-time recognition: Processes video streams in real time during the movement of the track robot and outputs counting results instantly; High precision: The area is corrected through perspective transformation, reducing errors caused by camera angle and distance; Anti-occlusion: Through the processing of rasterized areas and overlapping areas, it can accurately count even when partially occluded; Adaptive: Adapts to different pen sizes and shapes, as well as different pig postures. Attached Figure Description

[0013] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and constitute a part of this invention, are not intended to limit the scope of the invention. In the drawings: Figure 1 Flowchart of a method for identifying pigs on a tracked robot under weak network conditions, provided as an exemplary embodiment of the present invention; Figure 2 A pigsty configuration diagram provided for an exemplary embodiment of the present invention; Figure 3 This is a fisheye camera image recognition diagram provided as an exemplary embodiment of the present invention. Detailed Implementation

[0014] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention.

[0015] The technical concept of this invention is as follows: A track-mounted robot carrying a computing module and a fisheye camera moves along a track to scan pig pens. It identifies pigs using a local AI model and employs rasterized region management and perspective transformation to correct for size variations caused by camera angle and distance, thereby ensuring accurate counting.

[0016] The present invention provides a method for identifying pigs on a track-mounted robot under weak network conditions, which aims to solve the above-mentioned technical problems in the prior art.

[0017] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.

[0018] Example 1: 1. System initialization: The track robot starts, loads the AI ​​model and the preset pigpen grid map, and initializes the camera parameters (intrinsic parameters, extrinsic parameters) and perspective transformation matrix; 2. The track-based robot moves along the track, such as... Figure 2 As shown, the lines running through pigsties 1, 2, and 3 form a track, and the fisheye camera on the track robot continuously collects images. Figure 3 As shown, the localization system (UWB) provides the robot's position in real time; 3. Divide the pigpen area into multiple grids (50cm×50cm). Adjacent grids have overlapping areas. When the robot moves, it processes each grid in sequence according to the direction of travel. 4. For the current frame image, use the YOLOv8-Instance model mounted on the edge intelligent computing module to detect pigs, obtain the bounding box and instance segmentation mask of each pig, and map the detected pigs into the corresponding grid according to the robot's current position; 5. When the robot moves above the overlapping area of ​​two grids, the overlap processing is triggered. For the pigs in the overlapping area, the robot slides along the vertical line of its direction of travel and analyzes the area change of the pigs in the two frames before and after. The two frames before and after are two average frames. That is, in order to balance the static and dynamic environmental changes during the sampling period, the average of multiple adjacent frames is taken as the data of the previous frame and the next frame. The multiple adjacent frames are video frames with timestamps corresponding to the vertical line. 6. Based on the camera's position and angle, and the assumption that the pig is on the ground, convert the pixel area to the real-world area through perspective transformation, calculate the corrected area of ​​the pig in two adjacent grids, and analyze whether the area change conforms to the expectation of perspective transformation. 7. Determine whether it is the same pig by the area change trajectory to avoid duplicate counting, update the pig count of the current grid, and merge the counts of adjacent grids; 8. Once the robot has scanned the entire pigpen, output the total count result.

[0019] Example 2: Based on the method of Example 1, the system configuration parameters are shown in Table 1: Table 1 System Configuration Parameters Components Technical parameters Orbital robot Moving speed: 0.3-0.5 m / s; Positioning accuracy: ±1 cm fisheye camera 1920×1080@30fps, 185° wide-angle Edge computing unit 8GB RAM, 21 TOPS computing power Positioning system Resolution 0.1mm, sampling rate 100Hz Step 1: System Initialization The orbital robot starts, loading a pre-trained YOLOv8-Instance model and a pigpen grid map. Camera parameters are initialized: intrinsic matrix K = [[800, 0, 960], [0, 800, 540], [0, 0, 1]], distortion coefficients D = [-0.3, 0.1, 0.001, -0.0005]. The extrinsic matrix is ​​calculated based on an installation height of 2.5m and a tilt angle of 45°. A 10m × 6m pigpen grid map is created: number of rows = ceil(10 / 0.5) = 20, number of columns = ceil(6 / 0.5) = 12, overlap width = 0.5 × 0.15 = 0.075m. Step 2: Image Acquisition and Preprocessing The orbital robot moves along the track at a speed of 0.4 m / s, and a fisheye camera captures images at 30 fps. Fisheye distortion correction and image enhancement are performed on each frame. Step 3: Pig inspection and segmentation The enhanced image is input into the YOLOv8-Instance model, and the output detection results are as follows: Figure 3 As shown: [320, 180, 450, 320], bounding box, binary_mask, segmentation mask, 0.78, confidence score, pig, category; If 0.78 >= 0.5, retain the test result; Step 4: Calculate the area of ​​perspective transformation For each detected pig, calculate the real-world area: Obtain the bottom center point of the mask, calculate the ground coordinates of the point, calculate the area per unit pixel, calculate the pixel area, and calculate the actual area (adding a height correction factor of 1.2). Step 5: Processing overlapping areas When the robot enters the overlapping area of ​​grid A (3,4) and grid B (3,5), the following average frames are collected: First average frame: 5 frames are collected within 0.5 seconds before entering the overlapping area to generate a weighted average frame; Second average frame: 5 frames are collected within 0.5 seconds after entering the overlapping area to generate a weighted average frame. The matching algorithm is as follows: def match_pigs_in_overlap(prev_pigs, next_pigs): matches = [] for prev_pig in prev_pigs: best_match = None min_error = float('inf') for next_pig in next_pigs: # Calculate distance difference distance = np.linalg.norm( prev_pig['ground_point']- next_pig['ground_point']) if distance < 0.3: # Distance threshold # Calculate the theoretical area ratio d_prev = np.linalg.norm(prev_pig['ground_point']) d_next = np.linalg.norm(next_pig['ground_point']) expected_ratio = (d_next**2+ 2.5**2) / (d_prev**2 +2.5**2) # Calculate the actual area ratio actual_ratio = prev_pig['area'] / next_pig['area'] # Calculation error ratio_error = abs(actual_ratio - expected_ratio) if ratio_error<0.2 and ratio_error <min_error: min_error = ratio_error best_match = next_pig if best_match is not None: matches.append((prev_pig, best_match)) return matches Step 6: Count Update and Output Maintain a global list of pigs to avoid duplicate counting: The fully offline pig identification method obtained through this embodiment.

[0020] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0021] Furthermore, in the embodiments of the present invention, the functional modules can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or in the form of hardware plus software functional modules.

[0022] Those skilled in the art will understand that embodiments of the present invention can be provided as methods or systems. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects.

[0023] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0024] The above are merely embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.

[0025] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the invention disclosed herein in the specification and examples. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the foregoing claims.

[0026] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A method for pig identification on a tracked robot under weak network conditions, characterized in that, Includes the following steps: A rasterized map of the pigsty was created, and a mapping relationship from image pixel coordinates to ground world coordinates was established. Distortion correction is used to collect images of a robot traveling on a track above the pigsty, identify pigs, and obtain the bounding box and segmentation mask for each pig. The number of pixels is calculated based on the segmentation mask, and the perspective transformation is used to obtain the true area. When the track robot moves across the overlapping area, the frames collected before and after belong to different grids. By analyzing the area change of the same pig in the frames before and after, it can be determined whether it is the same pig. Update the pig count based on the overlapping region matching results and output the total number of pigs identified.

2. The method for identifying pigs on a tracked robot under weak network conditions according to claim 1, characterized in that, The process of creating a rasterized map of the pigsty and establishing a mapping relationship from image pixel coordinates to ground world coordinates specifically includes: Initialization process: Load the AI ​​model and grid map from the computing module on the orbital robot, and initialize the camera parameters; Obtain the camera intrinsic parameter matrix K and distortion coefficients. Based on the installation height and angle, determine the camera's extrinsic parameters relative to the ground, including the rotation matrix R and translation vector t. Establish the perspective transformation matrix. Based on the intrinsic and extrinsic parameters, establish the mapping relationship from image pixel coordinates to ground coordinates. The data to be entered is: pigpen length is L, width is W, and grid size is a×a; Number of grid cells: number of rows = ceil(L / a), number of columns = ceil(W / a); The overlap ratio of adjacent grid cells is set to r, and the overlap width is a*r.

3. The method for identifying pigs on a trackless robot under weak network conditions according to claim 2, characterized in that, The distortion correction process involves capturing images from the orbiting robot above the pigsty, identifying pigs, and obtaining the bounding box and segmentation mask for each pig. Specifically, this includes: The distortion coefficients calibrated by the camera on the track robot are used to perform algorithmic correction of the fisheye camera images through OpenCV in the AI ​​model mounted on the track robot, including contrast enhancement and histogram equalization. The image is input into the instance segmentation model carried by the track robot, which outputs the bounding box (x1, y1, x2, y2), confidence score, category, and segmentation mask for each detected pig, and filters out detection results with a confidence score below the threshold of 0.

5.

4. The method for identifying pigs on a trackless robot under weak network conditions according to claim 3, characterized in that, The process of calculating the number of pixels based on a segmentation mask and transforming the perspective into the true area includes: For each detected pig, the pixel area, i.e. the number of pixels, is calculated using its segmentation mask; By using perspective transformation, the pixel area is converted into the real-world area; Specifically: Find the lowest point of the pig mask, which is the point where the pig touches the ground, and take that point as the pig's ground position. Using camera parameters and the ground plane equation, calculate the real-world coordinates corresponding to this ground location; Calculate the ground area corresponding to each pixel, and then multiply it by the pixel area to obtain the actual area.

5. The method for identifying pigs on a trackless robot under weak network conditions according to claim 4, characterized in that, The process involves analyzing the area changes of the same pig in the preceding and following frames, which are collected when the orbital robot crosses an overlapping area, and determining whether they belong to the same grid. This includes: The robot moves in the x-direction, and the overlapping area is the overlapping part of two adjacent grids A and B; When the robot enters the overlapping area, it records the pig data in the overlapping area of ​​the current frame belonging to grid A and the next frame belonging to grid B. For each pig in grid A, find a matching pig in grid B, with the following matching criteria: In the ground coordinates after perspective transformation, the distance between the two pigs is less than the threshold. If the area of ​​the two pigs changes within the threshold range, that is, if the height of the robot camera is H and the horizontal distance from the pig to the bottom of the camera is d, then the distance from the camera to the pig is sqrt(d^2 + H^2), and the area is proportional to 1 / (d^2 + H^2).

6. The method for identifying pigs on a tracked robot under weak network conditions according to claim 5, characterized in that, The preceding and following frames also specifically include: During the movement of the orbital robot, when it approaches the overlapping area, the camera captures multiple frames of images at two key positions, namely position A and position B: Position A: just before the robot enters the vertical line of the overlapping area, about to enter the overlapping area; Position B: after the robot has fully entered the vertical line of the overlapping area, just after it has fully entered the overlapping area. At each location, the camera captures N consecutive frames of images, and then calculates the average of these N frames, which are used as the previous and next frames, respectively.

7. The method for identifying pigs on a trackless robot under weak network conditions according to claim 6, characterized in that, The process of updating the pig count based on the overlapping region matching results and outputting the total number of identified pigs specifically includes: The initial count is 0. For each grid, the unique ID of the pigs that have been counted is recorded. When processing a new grid, only pigs that have not appeared in the previous grid are counted. After the track robot travels to the end of a pig pen, the total number of pigs identified is accumulated and output, which is recorded as the total number of pigs in the current pig pen.

Citation Information

Patent Citations

  • Road surface disease target detection and instance segmentation method based on road foreground image

    CN111553236A

  • Method and device for detecting ships entering and leaving port

    CN112818789A

  • Pig counting method for fixed channel

    CN114119648A

  • AI video counting method for pig breeding

    CN115359382A