Cowhouse marking plate recognition method for cattle position judgment

By using a two-level detection method with ArUco and AprilTag identification codes and perspective transformation technology in cattle sheds, combined with Kalman filters and exponential smoothing, the problem of poor identification accuracy of marker boards in cattle shed environments was solved, achieving high-precision and stable ROI positioning, and reducing operation and maintenance costs and complexity.

CN121809503APending Publication Date: 2026-04-07CHANGZHOU WUITU SMART TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing tagging technology is ill-suited to the complex environment of cattle sheds, resulting in poor recognition accuracy.

Method used

A two-level label detection method based on ArUco and AprilTag identification codes is adopted, which combines perspective transformation and Kalman filtering techniques. Image processing is performed by local adaptive thresholding and Canny edge detection to screen candidate boxes and correct distortion. Kalman filter and exponential smoothing techniques are used to stabilize the ROI region.

Benefits of technology

The system improved the detection rate of marker boards and the accuracy of ROI positioning in the complex environment of cattle sheds, reduced system latency, supported 24/7 operation, simplified deployment and maintenance, and reduced manual labeling and software development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809503A_ABST
    Figure CN121809503A_ABST
Patent Text Reader

Abstract

The invention relates to an image recognition technology, in particular to a cattle house marking plate recognition method for cattle position judgment, which comprises the following steps: data acquisition: acquiring a marking plate image, and setting two different identification codes ArUco and AprilTag on a marking plate; the method comprises the following steps: identifying a marking plate, generating a region of interest, carrying out preliminary contour extraction along with a grayed image, obtaining a candidate frame, carrying out two-stage screening on the candidate frame, and then carrying out distortion correction on the screened candidate frame image. According to the method, through two-stage tag detection (ArUco + AprilTag), precise perspective transformation normalization and a dynamic homography matrix optimization technology fusing Kalman filtering and exponential smoothing, the detection rate of the marking plate is improved in a complex cowshed environment (such as strong backlight, stains, dust and shielding), and the ROI positioning precision and stability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to image recognition technology, and more particularly to a method for recognizing cattle shed markers for determining the location of cattle. Background Technology

[0002] In modern livestock management, cattle location monitoring is a crucial step in optimizing breeding efficiency and ensuring animal welfare. Traditional methods rely on manual inspections or video surveillance systems combined with ROI (Real Area of ​​Interest) algorithms to determine the presence and location of cattle in the barn. However, existing technologies have the following drawbacks: Reliance on manual annotation: Traditional algorithms require pre-annotating fixed ROI areas in the video frame, but on-site construction personnel lack professional knowledge of the algorithm, which can easily lead to a mismatch between the annotated area and the algorithm requirements, resulting in misjudgments.

[0003] Remote annotation is inefficient: Some companies use remote annotation solutions by algorithm engineers, but due to network latency and device compatibility limitations, it is difficult to make real-time dynamic adjustments, affecting deployment flexibility.

[0004] Poor adaptability: The complex environment of the cattle shed (such as changes in lighting, obstructions, etc.) makes it difficult for the static ROI to adapt to dynamic scenarios, resulting in insufficient robustness of the algorithm. Summary of the Invention

[0005] The technical problem solved by this invention is that existing marker recognition technology is difficult to adapt to the complex environment of cattle sheds, resulting in poor recognition accuracy.

[0006] Therefore, the present invention provides a method for determining the location of cattle based on marker board recognition.

[0007] The technical solution adopted by this invention to solve its technical problem is: A method for identifying cattle shed markers for determining cattle location, characterized by comprising: Step 1: Data acquisition. Acquire images of the marker board, which has two different identification codes: ArUco and AprilTag. Step 2: Marker recognition and region of interest generation. Preliminary contour extraction is performed on the grayscale image to obtain candidate boxes. The candidate boxes are then filtered in two stages, and distortion correction is performed on the filtered candidate box images.

[0008] Furthermore, the four corners of the marking plate use the identifier "ArUco", and the central part uses the identifier "AprilTag". The two identifiers do not overlap.

[0009] Furthermore, step two specifically includes the following steps: Image processing: Convert the image to grayscale and binarize it using a local adaptive thresholding method to automatically enhance the black and white contrast to adapt to the instantaneous changes in light in the cowshed; Canny edge detection extracts contours and obtains candidate boxes to form a candidate set; Candidate box filtering: Based on the candidate box filtering using the OpenCV ArUco library, the AprilTag C library is used to perform a second filtering of the selected candidate boxes; Information association: The filtered physical_id, aruco_id, and apriltag_id are associated based on their IDs through an offline mapping table; Distortion correction: Perform a four-point perspective transformation on the four corner points of the candidate box to eliminate distortion; Stabilize ROI: Keep the region of interest in the correct position even when the camera or marker moves slightly. If the average error exceeds 3 px for 30 consecutive frames, issue a drift alarm via MQTT.

[0010] Furthermore, in the information association step, if both aruco_id and apriltag_id match and the corner difference is less than 3px, then the average corner value of the two is taken.

[0011] Furthermore, in step two, if the same ID is repeatedly associated in the offline mapping table, non-maximum suppression is performed using projection error to leave the most reliable box.

[0012] Furthermore, within the stable ROI region, temporally, a Kalman filter is used to convert the homography matrix Ht of the previous frame. 1H_{t-1}Ht 1. Extrapolate to the current frame and then correct with the measured value to reduce the standard deviation of ROI jitter; at the same time, perform exponential smoothing on the real-time observed homography matrix HtH_tHt and the historical value to achieve dynamic homography. Add a "first-order low-pass filter" to the newly calculated homography matrix for each frame to weaken high-speed jitter and retain only slow, real displacement.

[0013] A computer device, comprising: processor; Memory, used to store executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the cattle shed marker identification method for determining the location of cattle as described above.

[0014] A computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the cattle shed marker identification method for determining the location of cattle as described above.

[0015] The beneficial effects of this invention are that, through innovative dual-level label detection (ArUco + AprilTag), precise perspective transformation normalization, and dynamic homography matrix optimization technology that integrates Kalman filtering and exponential smoothing, it improves the detection rate of marker boards in complex environments such as cattle sheds (e.g., strong backlighting, stains, dust, and occlusion), and enhances ROI positioning accuracy and stability. The system has extremely low processing latency, easily supporting real-time processing, and can achieve all-weather operation when combined with IR supplemental lighting. It significantly reduces manual labeling costs and software development complexity, providing an intuitive real-time visual ROI adjustment interface that greatly simplifies deployment and maintenance, enabling even untrained personnel to operate easily, effectively lowering the overall operation and maintenance threshold and cost. Attached Figure Description

[0016] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0017] Figure 1 This is a schematic diagram of the marker recognition process in this invention.

[0018] Figure 2 This is a schematic diagram of the marker plate identified in this invention. Detailed Implementation

[0019] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0020] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, features defined with "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0021] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0022] A method for determining the location of cattle based on marker recognition, specifically including: Step 1: Place marker boards in key areas of the cattle shed, such as feed troughs and passageway entrances. By identifying the marker boards, determine which area of ​​the cattle shed the cattle are in.

[0023] In this embodiment, the marking plate is 25 cm × 25 cm in size, with an anti-reflective matte PET surface and a stain-resistant coating to ensure day and night visibility. Furthermore, the four corners are printed with ArUco 4×4_50, and the central part is printed with AprilTag 36h11. The corner printing and the central printing do not overlap.

[0024] Step 2, Data Collection A wide-angle camera is mounted on the top or wall of the cattle shed, with camera parameters of 1080p @ 30 fps, and the signal is transmitted to the edge computing box (Jetson / RK3588) using H.264 / H.265 RTSP.

[0025] Step 3: Marker identification and Region of Interest (ROI) generation Based on the OpenCV ArUco + AprilTag C library, the coordinates of the marker board are detected in real time, and a ROI aligned with the marker board position is dynamically generated using perspective transformation, with an error ≤ 1 px. The specific marking process is as follows: S3.1 Image Processing The system extracts images from video data and performs adaptive thresholding binarization on the images. First, each frame is converted into a grayscale image and then binarized using a local adaptive thresholding method. The black and white contrast is automatically enhanced to adapt to the instantaneous changes in lighting inside the cattle shed.

[0026] S3.2 Contour Detection Contours are extracted using Canny edge detection, and after connected component analysis, only candidate boxes that are approximately square and have an area that reaches a threshold are retained to form a candidate set (qualified candidate boxes are obtained), thereby quickly filtering out a large number of irrelevant textures.

[0027] S3.3 Candidate Box Filtering Perform two-level filtering on the candidate boxes: Stage-A calls cv::aruco::detectMarkers() to search for ArUco 4×4_50 subscripts (aruco dictionary format) in all candidates based on the OpenCV ArUco library, with an average time of only 0.2 ms, and can hit more than 90% of the markers; Stage-B uses AprilTag 36h11 for rejected candidate boxes to salvage backlit or partially occluded scenes, which can recover an additional 8–12% of detections.

[0028] S3.5 In the candidate extraction stage, the system detects several regions that may contain identifier codes from the input image and obtains the corner coordinates of these regions. Each region is returned, and the physical_id (marker number detected by the ArUco algorithm), aruco_id (marker number detected by the AprilTag algorithm), and apriltag_id (marker number in physical space) are associated based on their ID numbers through an offline mapping table. If both aruco_id and apriltag_id match and the corner difference is less than 3 px, the average corner point of the two is taken to further improve the positioning accuracy.

[0029] S3.6 then performs a four-point perspective transformation on these four corner points. Given the coordinates (xi, yi) of the four corner points of the marker board in the original image, i∈{0,1,2,3}, first set a preset square coordinate system: (0,0), (0,99), (99,0), (99,99). Use a homography matrix to represent the relationship between the corner points (xi, yi) and the preset square coordinates. Then, perform a perspective transformation to straighten this tilted and distorted rectangle into a regular 100 × 100 px square patch. Subsequent models can then treat it as a small image taken from a "level view." This normalizes the marker board of arbitrary poses into a 100 × 100 px square patch, completely eliminating distortion. Why do this? Because the camera and the marker board are often not on the same plane, the shooting angle is tilted, and lens distortion and perspective effects cause the marker board to appear distorted in the image. It appears as a trapezoid or twisted shape.

[0030] S3.7 If the same ID is detected multiple times in a frame, non-maximum suppression is performed using projection error, leaving only the most reliable frame.

[0031] S3.8 allows the ROI to remain "stuck" in the correct position even when the camera or marker is slightly displaced.

[0032] In terms of timing, the system uses a Kalman filter to convert the homography matrix Ht of the previous frame. 1H{t-1}Ht Extrapolate to the current frame and then correct using measured values ​​to reduce the ROI jitter standard deviation from 1.8 px to 0.7 px; at the same time, perform exponential smoothing (smoothing coefficient α = 0.2) on the real-time observed homography matrix HtHtHt and historical values ​​to achieve dynamic homography. Add a "first-order low-pass filter" to the newly calculated homography matrix for each frame to reduce high-speed jitter (noise) and retain only slow, real displacement, so that the ROI will not "jiggle" but can automatically follow when the camera or marker is moved slowly.

[0033] Homography matrix Ht 1H{t-1}Ht The homography matrix Ht is a 3×3 matrix that describes the perspective transformation between two images on the same plane. If you move the camera slightly or the marker board is slightly tilted, the homography matrix Ht can describe "the overall change of this frame compared to the previous frame". Therefore, the location of the ROI (Region of Interest) can be predicted and updated using this matrix.

[0034] If the average error exceeds 3 pixels for 30 consecutive frames, a drift alarm is issued via MQTT, prompting on-site personnel to check the lens or reattach the marker. This bottom-up processing chain ensures that even in the complex lighting and dust environment of the cattle shed, the system can still lock the marker with pixel-level accuracy and complete the ROI update within 200 ms, laying a stable, efficient, and low-maintenance foundation for the entire intelligent monitoring application.

[0035] It should be noted that this application uses two identification codes, ArUco and AprilTag, for marker board recognition. It employs a cascaded dual-dictionary + candidate sharing scheme. At the beginning, all the small blocks to be identified from all the marker boards are selected to form a unified candidate set, which is then reused subsequently, thus avoiding repeated identification of small blocks. This scheme reduces computational load by approximately 40% compared to simply identifying two codes using a single dictionary. Secondly, this application uses corner point fusion calibration and a weighted average method to fuse information from the two different identification codes. The innovation lies in the fusion process; firstly, the corner points need to be... To align the data, the order is aligned counter-clockwise. Next, the Euclidean distance is calculated to determine if the identification codes are features of the same board. After the determination, the error is measured, and the projection error is calculated for each corner point. Finally, the fused matrix contains information from both codes. Then, a two-stage robustness mechanism is used, along with a robustness mechanism and a non-recursive smoother. The smoother reduces image jitter and flicker. Flattening the vector obtained in the previous step is mainly to reduce error and prevent image jitter during calibration. This method can process the information of all four corner points at once. Example 2 This application provides a computer device including a processor and a memory. The memory stores at least one instruction or at least one program. The at least one instruction or at least one program is loaded and executed by the processor to implement a cattle shed marker identification method for determining the location of cattle, as provided in the above method embodiment.

[0036] Example 3 This application embodiment also provides a computer-readable storage medium, which can be disposed in a server to store at least one instruction or at least one program segment related to implementing a cattle shed marker identification method for cattle location determination in the method embodiment. The at least one instruction or at least one program segment is loaded and executed by the processor to implement the cattle shed marker identification method for cattle location determination provided in the above method embodiment. Optionally, in this embodiment, the storage medium can be located in at least one of multiple network servers in a computer network. Optionally, in this embodiment, the storage medium can include, but is not limited to, various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0037] In summary, this application improves the detection rate of marker boards in complex environments such as cattle sheds (e.g., strong backlighting, stains, dust, occlusion) through innovative dual-level label detection (ArUco + AprilTag), precise perspective transformation normalization, and dynamic homography matrix optimization technology that integrates Kalman filtering and exponential smoothing. This also enhances the accuracy and stability of ROI positioning. The system exhibits extremely low processing latency, easily supporting real-time processing, and enables all-weather operation when combined with IR supplemental lighting. It significantly reduces manual labeling costs and software development complexity, providing an intuitive real-time visual ROI adjustment interface that greatly simplifies deployment and maintenance, allowing even untrained personnel to operate easily, effectively lowering the overall operational threshold and cost.

[0038] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined by the scope of the claims.

Claims

1. A method for identifying cattle shed markers for determining cattle location, characterized in that, include, Step 1: Data acquisition. Acquire images of the marker board, which has two different identification codes: ArUco and AprilTag. Step 2: Marker recognition and region of interest generation. Preliminary contour extraction is performed on the grayscale image to obtain candidate boxes. The candidate boxes are then filtered in two stages, and distortion correction is performed on the filtered candidate box images.

2. The method for identifying cattle shed markers for determining cattle location according to claim 1, characterized in that, The marking plate uses the identifier "ArUco" at the four corners and "AprilTag" in the center, with the two identifiers not obscuring each other.

3. The method for identifying cattle shed markers for determining cattle location according to claim 1, characterized in that, Step two specifically includes the following steps: Image processing: Convert the image to grayscale and binarize it using a local adaptive thresholding method to automatically enhance the black and white contrast to adapt to the instantaneous changes in light in the cowshed; Canny edge detection extracts contours and obtains candidate boxes to form a candidate set; Candidate box filtering: Based on the candidate box filtering using the OpenCV ArUco library, the AprilTag C library is used to perform a second filtering of the selected candidate boxes; Information association: The filtered physical_id, aruco_id, and apriltag_id are associated based on their IDs through an offline mapping table; Distortion correction: Perform a four-point perspective transformation on the four corner points of the candidate box to eliminate distortion; Stabilize ROI: Keep the region of interest in the correct position even when the camera or marker moves slightly. If the average error exceeds 3 px for 30 consecutive frames, issue a drift alarm via MQTT.

4. The method for identifying cattle shed markers for determining cattle location according to claim 3, characterized in that, In the information association step, if both aruco_id and apriltag_id match and the corner difference is less than 3 px, then the average corner value of the two is taken.

5. The method for identifying cattle shed markers for determining cattle location according to claim 3, characterized in that, In step two, if the same ID is repeatedly associated in the offline mapping table, non-maximum suppression is performed using projection error to leave the most reliable box.

6. The method for identifying cattle shed markers for determining cattle location according to claim 3, characterized in that, In the stable ROI region, temporally, a Kalman filter is used to convert the homography matrix Ht of the previous frame. 1H_{t-1}Ht 1. Extrapolate to the current frame and then correct with the measured value to reduce the standard deviation of ROI jitter; at the same time, perform exponential smoothing on the real-time observed homography matrix HtH_tHt and the historical value to achieve dynamic homography. Add a "first-order low-pass filter" to the newly calculated homography matrix for each frame to weaken high-speed jitter and retain only slow, real displacement.

7. A computer device, characterized in that, include: processor; Memory, used to store executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the cattle shed marker identification method for determining the location of cattle as described in any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to implement the cattle shed marker identification method for determining the location of cattle as described in any one of claims 1 to 6.