Channel livestock real-time video counting method and system based on active learning
By using a binary classification YOLO model based on active learning and a target tracking algorithm, livestock movement trajectories are generated and counted using standard lines. This solves the problems of obtaining training data and linking information between video frames in livestock counting, enabling real-time and accurate livestock counting and improving the level of intelligent livestock management.
Patent Information
- Application Number
- CN202511230370.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-12-12
AI Technical Summary
Existing livestock counting technologies suffer from difficulties in acquiring training data, difficulty in correlating information between video frames, and difficulty in achieving real-time counting.
An active learning-based approach is adopted, which uses a pre-trained binary YOLO model to detect livestock targets, combines a target tracking algorithm to generate movement trajectories, and uses a preset standard line to achieve counting. The model is optimized through an active learning mechanism.
It enables stable and accurate real-time counting of continuously passing livestock in complex scenarios, significantly improving the level of automated management in large-scale farming scenarios, and combining economic efficiency with environmental adaptability.
Smart Images

Figure CN121121601A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of real-time video counting technology, specifically relating to a method and system for real-time video counting of livestock in a passageway based on active learning. Background Technology
[0002] In today's society, with the continuous improvement of living standards, the demand for meat products is increasing daily, which has strongly promoted the vigorous development of animal husbandry. Under modern farming models, standardized management has become an indispensable and important link in ensuring the efficient and stable development of animal husbandry. Among them, livestock counting, as a fundamental and crucial link, is directly related to the economic benefits and management effectiveness of farms. Accurately grasping the number of livestock plays a decisive role in the rational allocation of breeding resources and the planning of sales strategies.
[0003] Currently, various counting methods exist in the field of livestock counting. Traditional manual counting methods require significant manpower and time, and are prone to errors due to worker fatigue and negligence. While still used in some small farms or special scenarios, they clearly cannot meet the needs of large-scale, high-efficiency farming. RFID-based counting methods, which use electronic ear tags on livestock and readers to identify information and upload it to the management system, offer some improvement in accuracy. However, the high cost of RFID tags and readers places a significant financial burden on enterprises during large-scale deployment. Furthermore, this technology is significantly affected by environmental factors; for example, metal or liquid environments can affect signal transmission and reduce counting accuracy. Infrared-based counting methods are highly demanding in terms of environmental conditions. Strong light, dust, and humidity can all negatively impact the performance of infrared sensors. Moreover, this method requires livestock to pass through a specific channel individually; if a group of livestock passes through, missed or incorrect counts are highly likely. Counting methods based on image and video analysis encompass both static image counting and dynamic video counting. When livestock are severely overlapped or occluded, static image counting models trained with computer vision technology struggle to accurately identify and count them, leading to a significant drop in accuracy. While dynamic video counting compensates for some of the shortcomings of static image counting to a certain extent, it faces numerous technical challenges in practical applications, such as difficulties in acquiring training data, the need for large amounts of data to train models, and how to effectively correlate information between video frames, achieve global real-time counting of livestock across the entire video, and store the results in a database.
[0004] In summary, existing livestock counting technologies suffer from a series of problems, including difficulty in acquiring training data, difficulty in effectively correlating information between video frames, and difficulty in achieving real-time counting. Summary of the Invention
[0005] This invention provides a method and system for real-time video counting of livestock in a passageway based on active learning. This method solves the problems of difficulty in obtaining training data, difficulty in correlating information between video frames, and real-time counting in the prior art.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: A method for real-time video counting of livestock in a passageway based on active learning, comprising: The real-time video to be analyzed is input into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; The target's motion trajectory is obtained by combining multiple detection results from the video with a target tracking algorithm. The targets whose motion trajectories intersect with the standard line are counted to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0007] Furthermore, the real-time video to be analyzed is input into a pre-trained livestock detection model, and the training process of the livestock detection model is as follows: Video frames are extracted from historical livestock video data to obtain the original training images; The original training images are selected and labeled to obtain the labeling results; Save the annotation results as an annotation file in YOLO format; The original training images and labeled files are randomly divided into training and validation sets; The YOLO model with a binary classification head was trained using the training set to obtain a well-trained livestock detection model.
[0008] Furthermore, the livestock detection model only identifies two categories: livestock and background.
[0009] Furthermore, the step of inputting the real-time video to be analyzed into a pre-trained livestock detection model to detect multiple detection results in the video includes: Read the video stream of the real-time video to be analyzed and scale the video stream to a fixed size; The scaled video stream frames are input into a pre-trained livestock detection model, which outputs the detection results; the detection is performed once every preset period.
[0010] Furthermore, the method of obtaining the target motion trajectory by combining multiple detection results obtained from the video with a target tracking algorithm includes: Based on the correlation between adjacent frames, the detection results of adjacent frames in the video are matched. After a successful match, the motion trajectory of the object between adjacent frames is obtained. The matching process is repeated until all the target motion trajectories in the video are obtained.
[0011] Furthermore, the counting and statistical analysis of targets whose motion trajectories intersect with the standard line includes: If the target's trajectory intersects the standard line and the target's direction of movement gradually approaches the camera, the "entry" count is incremented by one. If the target's trajectory intersects the standard line and the target's direction of movement gradually moves away from the camera, the "out" count is incremented by one.
[0012] Furthermore, after inputting the real-time video to be analyzed into a pre-trained livestock detection model to obtain multiple detection results in the video, the process further includes: The livestock detection model was retrained by selecting low-confidence video frames, including: During the real-time video detection process, screenshots are taken of target scenes in selected areas where the built-in confidence level is lower than the preset confidence level in order to obtain training images; After labeling the training images using an online data annotation platform, the livestock detection model was retrained.
[0013] A real-time video counting system for livestock in a passageway based on active learning, comprising: The detection module is used to input the real-time video to be analyzed into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; The trajectory calculation module is used to obtain the target motion trajectory based on multiple detection results in the detected video and a target tracking algorithm. The counting and statistics module is used to count and statistically analyze targets whose motion trajectories intersect with the standard line to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0014] A real-time video counting device for livestock in a passageway based on active learning, comprising: Memory, used to store computer programs; A processor is used to implement the steps of the above-described active learning-based real-time video counting method for livestock in the channel when executing the computer program.
[0015] A computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the steps of the above-described active learning-based real-time video counting method for livestock.
[0016] Compared with the prior art, the present invention has the following beneficial effects: This invention provides a real-time livestock counting method based on active learning in video feeds. The method uses a pre-trained YOLO binary classification livestock detection model to detect livestock in real-time video, combines this with a target tracking algorithm to generate motion trajectories, and uses the intersection points of preset standard lines and trajectories to achieve counting. A lightweight binary YOLO model is employed to reduce computational complexity, occlusion problems are solved by associating target tracking with inter-frame information, and duplicate counting is avoided using a standard line intersection determination mechanism. This method effectively overcomes the problems of low efficiency in traditional manual counting, high cost of RFID, and susceptibility to infrared interference. Dynamic video analysis solves the problem of overlapping false detections in static images, while active learning continuously optimizes the model. Ultimately, it achieves stable and accurate real-time counting of continuously passing livestock in complex scenarios, significantly improving the level of automated management in large-scale livestock farming scenarios, and is both economical and environmentally adaptable.
[0017] Preferably, in this invention, the generalization ability and robustness of the livestock detection model are ensured through standardized data annotation and training processes. Historical video data is extracted and labeled, stored in YOLO format, and divided into training and validation sets, enabling the model to fully learn livestock features. The training process of the binary YOLO model simplifies the model structure, improves detection efficiency, and reduces the complexity of data annotation and model training, facilitating practical deployment and application.
[0018] Preferably, in this invention, the livestock detection model is limited to recognizing only two classes: livestock and background, further optimizing the model's computational efficiency. The binary classification design reduces the number of model parameters, lowers computational resource consumption during inference, and avoids the confusion problems that may arise from multi-class classification, enabling the model to maintain high detection accuracy and real-time performance even in complex environments.
[0019] Preferably, in this invention, video stream scaling and periodic detection balance computational resource consumption and real-time detection performance. The fixed-size video input adaptation model requires a fixed input size, while the interval detection strategy reduces redundant computation, ensuring stable performance even during long-term operation. This method effectively reduces hardware resource requirements and is suitable for edge device deployment.
[0020] Preferably, in this invention, continuous tracking of livestock movement trajectories is achieved based on the matching and trajectory association of detection results from adjacent frames. This method can effectively handle situations of brief occlusion or overlap, and ensures the continuity of the trajectory through inter-frame correlation analysis, thereby improving the accuracy of counting and avoiding problems of missed or duplicate counting caused by target loss or mismatch.
[0021] Preferably, in this invention, a mechanism based on the intersection of the movement direction with a standard line is used to distinguish between the number of livestock "entering" and "leaving," thus achieving a two-way counting function. This design not only improves the precision of the counting but also provides more comprehensive data support for farm management, such as tracking livestock entry and exit, and further optimizing the breeding process.
[0022] Preferably, in this invention, by filtering low-confidence video frames and retraining the model, the detection system achieves continuous optimization and adaptive capabilities. During real-time detection, target images with insufficient confidence are automatically captured, labeled, and added to the training set, enabling the model to continuously learn new scene features and effectively cope with complex situations such as changes in lighting and occlusion. This active learning mechanism significantly improves the model's generalization performance, ensures counting accuracy in long-term use, and reduces the need for manual intervention, thus lowering maintenance costs. Attached Figure Description
[0023] Figure 1 A real-world image showing the application of the active learning-based real-time video counting method for livestock in a passageway to sheep counting, as provided in an embodiment of the present invention. Figure 2 A schematic diagram of a real-time video counting method for livestock based on active learning, provided in an embodiment of the present invention; Figure 3 The curve showing the change of mAP50 with the number of training epochs during YOLO training provided in this embodiment of the invention; Figure 4 A flowchart illustrating a real-time video counting method for livestock in a passageway based on active learning, provided as an embodiment of the present invention; Figure 5 This is a schematic diagram of a real-time video counting system for livestock based on active learning, provided as an embodiment of the present invention. Detailed Implementation
[0024] To further understand the content of this invention, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments are merely illustrative and not limiting of the invention.
[0025] The technical terms involved in this invention are explained below: mAP50 (mean Average Precision at IoU=0.50) is a core metric used to evaluate model performance in object detection tasks.
[0026] The following is a detailed explanation of the real-time video counting method for livestock based on active learning provided in this embodiment, with reference to the accompanying drawings: like Figure 4As shown, this embodiment provides a method for real-time video counting of livestock in a passageway based on active learning, including: The real-time video to be analyzed is input into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; The target's motion trajectory is obtained by combining multiple detection results from the video with a target tracking algorithm. The targets whose motion trajectories intersect with the standard line are counted to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0027] As can be seen, this method includes an active learning process that involves capturing video frames to obtain training data, labeling data, training the model, using the model to process the video, using the correlation information between video frames to obtain the motion trajectory of each object, counting the motion trajectory crossing the line, displaying the technical results and storing them in the database, displaying the counted video and the current count value in real time on the webpage, and filtering low-confidence video frames to relabel and retrain the model.
[0028] like Figure 1 and Figure 2 As shown, exemplarily, the real-time video counting method provided in this embodiment has the following specific steps: S1. Obtain training data.
[0029] S101. Using relevant tools, obtain the original training images by capturing video frames from the monitoring video.
[0030] S2. Label the data and divide the dataset.
[0031] S201. Build an online data annotation platform on the web, import the original image from S1, and annotate objects by selecting them with the mouse.
[0032] S202. The annotation results are saved as text files in YOLO format, with one annotation file corresponding to each image.
[0033] S203. Randomly divide the training set and validation set, with a ratio of 9:1.
[0034] S3. Build a deep learning network training model.
[0035] S301. The model used in this method is a modification of YOLO, changing the YOLO classification head from multi-class to binary classification, such as detecting only sheep (two categories: sheep and background).
[0036] S302. Use the original images obtained in S1 and the labeled data obtained in S2 to train the model. The model training is carried out on an Ubuntu server and 100 epochs are trained using an RTX3090 graphics card.
[0037] S4. Use the model obtained in S3 to perform inference on the video.
[0038] S401. Use OpenCV to read the video stream and scale the video to a fixed size.
[0039] S402. Input the scaled video frames into the model to obtain the detection results. Set the confidence level to 0.5. Since there is a lot of redundancy between the video frames, in order to ensure the real-time performance of inference, detect once every 3 frames.
[0040] S5. Based on the detection results obtained in S4, use the target tracking algorithm to obtain the target's motion trajectory.
[0041] S501. Based on the correlation between adjacent frames, the detection results of adjacent frames are matched. If the match is successful, the motion trajectory of the object between adjacent frames is obtained. By analogy, the entire motion trajectory of the target in the video frame can be obtained.
[0042] S6, Track crossing count.
[0043] Make a special mark on each side of the passage fence (such as inserting a small red flag on each side). The algorithm can automatically recognize the mark and connect the center points of the mark into a straight line as the standard line.
[0044] S601. Set a horizontal line in the middle of the channel in the video. The target moves vertically and gradually approaches the camera. When the target's trajectory intersects the horizontal line, the count value is incremented by one.
[0045] S602. If the target moves in the opposite direction, that is, gradually moves away from the camera, and the target's trajectory intersects the horizontal line, then the "out" count is incremented by one.
[0046] S7. Display the counting results and store them in the database.
[0047] S701. After the counting is completed, the counting result will be displayed on the corresponding device and stored in the database.
[0048] S702, integrate into relevant enterprise business systems.
[0049] S8: The webpage displays the counting video and the current count value in real time.
[0050] S801: The backend sends the current count value to the frontend in real time via WebSocket, and at the same time, the video processed by the model is sent to the frontend in real time via WebRTC.
[0051] S802: Build a webpage on the front end to control the start and end of the count, and display the current video frame and count value in real time.
[0052] S9. Filter out low-confidence video frames and retrain the model.
[0053] When processing videos, the models obtained from S901 and S3 extract target images with low confidence (less than 0.5) within the selected region to obtain the original training images.
[0054] S902. After labeling the data using S2's online data labeling platform, the model is retrained to improve counting accuracy.
[0055] For example, when training the model, the number of training epochs is set to 100; in actual deployment applications, the confidence level is set to 0.5; in active learning to filter targets with low confidence, the confidence level is set to 0.5, that is, targets with a confidence level lower than 0.5 and located in the specified area will be truncated.
[0056] In this embodiment, since the training data comes from the actual deployment environment (the training data comes from surveillance cameras, and the final deployment is also on the same surveillance cameras), the training and testing environments are basically the same, allowing the model to be trained and achieve a high accuracy rate. Furthermore, in actual deployment, this embodiment only focuses on sheep within the channel, as sheep within the channel are easier to detect than those outside, resulting in higher counting accuracy. Finally, through an active learning strategy, scenes where the model's learning is not optimal can be detected, and video frames can be extracted. Training data can then be obtained through annotation to retrain the model, improving its detection accuracy and consequently, its counting accuracy.
[0057] like Figure 3 As shown, Figure 3 The model's accuracy is shown to change with the number of training epochs, demonstrating that the method has high accuracy in object detection. When combined with trajectory information obtained from the correlation information between video frames and the line-crossing method, satisfactory results can be achieved in livestock counting.
[0058] Therefore, the active learning-based real-time video counting method for livestock in the passageway provided in this embodiment has the following advantages: This counting method, through an active learning strategy, alleviates the problem of insufficient data collection in custom datasets in industrial scenarios, thereby further improving the model's accuracy. By obtaining trajectories through correlation between video frames and using a trajectory-crossing method, counting accuracy can be improved. This method also enables real-time integration of the counting process and results into enterprise business systems, facilitating standardized management by enterprises.
[0059] like Figure 5 As shown, this embodiment also provides a real-time livestock video counting system based on active learning, including: a detection module, used to input the real-time video to be counted into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts a YOLO model with a binary classification head, trained based on historical livestock video data; a trajectory calculation module, used to obtain the target movement trajectory based on the multiple detection results in the detected video combined with a target tracking algorithm; and a counting and statistics module, used to count and count the targets whose movement trajectories intersect with the standard line to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0060] The present invention also provides a real-time video counting device for livestock in a passageway based on active learning, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the real-time video counting method for livestock in a passageway based on active learning.
[0061] When the processor executes the computer program, it implements the above-mentioned steps for real-time livestock video counting based on active learning. For example, the real-time video to be counted is input into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; the target movement trajectory is obtained by combining the multiple detection results in the video with a target tracking algorithm; the targets whose movement trajectories intersect with the standard line are counted to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0062] Exemplarily, the computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing preset functions, the instruction segments describing the execution process of the computer program in the active learning-based real-time livestock video counting device. For example, the computer program can be divided into a detection module, a trajectory calculation module, and a counting and statistics module; the specific functions of each module are as follows: the detection module is used to input the real-time video to be counted into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts a binary classification YOLO model, trained based on historical livestock video data; the trajectory calculation module is used to obtain the target movement trajectory based on the multiple detection results in the detected video combined with a target tracking algorithm; the counting and statistics module is used to count and statistically analyze targets whose movement trajectories intersect with a standard line to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
[0063] The active learning-based real-time video counting device for livestock can be a desktop computer, laptop, handheld computer, or cloud server, among other computing devices. This active learning-based real-time video counting device for livestock may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above examples of active learning-based real-time video counting devices for livestock do not constitute a limitation on such devices. The device may include more components than described above, or combine certain components, or use different components. For example, the active learning-based real-time video counting device for livestock may also include input / output devices, network access devices, buses, etc.
[0064] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or any conventional processor. This processor is the control center of the active learning-based real-time video counting system for livestock, connecting all parts of the active learning-based real-time video counting system for livestock using various interfaces and lines.
[0065] The memory can be used to store the computer program and / or modules. The processor implements various functions of the active learning-based real-time video counting device for livestock by running or executing the computer program and / or modules stored in the memory and calling the data stored in the memory.
[0066] The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, image playback, etc.). The data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0067] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the described method for real-time video counting of livestock based on active learning.
[0068] If the modules / units integrated in the active learning-based real-time video counting system for livestock are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
[0069] Based on this understanding, the present invention can implement all or part of the processes in the above-mentioned active learning-based real-time video counting method for livestock in passageways. This can also be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of the above-mentioned active learning-based real-time video counting method for livestock in passageways. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or a preset intermediate form, etc.
[0070] The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0071] It should be noted that the content contained in the computer-readable storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.
[0072] This invention provides a real-time video counting method for livestock in a passageway based on active learning, which has the following advantages compared to existing counting methods: This method detects livestock targets using a pre-trained binary YOLO model, generates motion trajectories using a target tracking algorithm, and achieves accurate counting using pre-defined standard lines. Its core advantages lie in using a lightweight binary classification model to reduce computational complexity, resolving occlusion issues through trajectory tracking, ensuring counting accuracy through a standard line intersection determination mechanism, and continuously optimizing model performance through an active learning mechanism. This method effectively overcomes the shortcomings of traditional manual counting (low efficiency), RFID (high cost), and infrared (susceptibility to interference). It solves the problem of overlapping false detections in static images through dynamic video analysis, improves real-time performance through periodic detection and inter-frame matching, and meets the needs of refined management through bidirectional counting. Ultimately, it achieves stable, efficient, and automated real-time counting of livestock in complex farming environments, significantly improving the intelligence level of large-scale farming management, and possessing economic efficiency, adaptability, and scalability.
[0073] The above embodiments are merely one of the implementation methods for achieving the technical solution of the present invention. The scope of protection claimed by the present invention is not limited to this embodiment, but also includes any variations, substitutions and other implementation methods that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention.
[0074] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for real-time video counting of livestock in a passageway based on active learning, characterized in that, include: The real-time video to be analyzed is input into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; The target's motion trajectory is obtained by combining multiple detection results from the video with a target tracking algorithm. The targets whose motion trajectories intersect with the standard line are counted to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
2. The method for real-time video counting of livestock in a passageway based on active learning according to claim 1, characterized in that, The real-time video to be analyzed is input into a pre-trained livestock detection model. The training process of the livestock detection model is as follows: Video frames are extracted from historical livestock video data to obtain the original training images; The original training images are selected and labeled to obtain the labeling results; Save the annotation results as an annotation file in YOLO format; The original training images and labeled files are randomly divided into training and validation sets; The YOLO model with a binary classification head was trained using the training set to obtain a well-trained livestock detection model.
3. The method for real-time video counting of livestock in a passageway based on active learning according to claim 2, characterized in that, The livestock detection model only identifies two categories: livestock and background.
4. The method for real-time video counting of livestock in a passageway based on active learning according to claim 1, characterized in that, The process involves inputting the real-time video to be analyzed into a pre-trained livestock detection model to obtain multiple detection results in the video, including: Read the video stream of the real-time video to be analyzed and scale the video stream to a fixed size; The scaled video stream frames are input into a pre-trained livestock detection model, which outputs the detection results; the detection is performed once every preset period.
5. The method for real-time video counting of livestock in a passageway based on active learning according to claim 1, characterized in that, The method of obtaining the target motion trajectory by combining multiple detection results obtained from the video with a target tracking algorithm includes: Based on the correlation between adjacent frames, the detection results of adjacent frames in the video are matched. After a successful match, the motion trajectory of the object between adjacent frames is obtained. The matching process is repeated until all the target motion trajectories in the video are obtained.
6. The method for real-time video counting of livestock in a passageway based on active learning according to claim 1, characterized in that, The counting and statistical analysis of targets whose trajectories intersect with the standard line includes: If the target's trajectory intersects the standard line and the target's direction of movement gradually approaches the camera, the "entry" count is incremented by one. If the target's trajectory intersects the standard line and the target's direction of movement gradually moves away from the camera, the "out" count is incremented by one.
7. The method for real-time video counting of livestock in a passageway based on active learning according to claim 1, characterized in that, After inputting the real-time video to be analyzed into a pre-trained livestock detection model to obtain multiple detection results in the video, the process further includes: The livestock detection model was retrained by selecting low-confidence video frames, including: During the real-time video detection process, screenshots are taken of target scenes in selected areas where the built-in confidence level is lower than the preset confidence level in order to obtain training images; After labeling the training images using an online data annotation platform, the livestock detection model was retrained.
8. A real-time video counting system for livestock in a passageway based on active learning, characterized in that, include: The detection module is used to input the real-time video to be analyzed into a pre-trained livestock detection model to detect multiple detection results in the video; wherein, the basic model of the livestock detection model adopts the YOLO model with a binary classification head, which is trained based on historical livestock video data; The trajectory calculation module is used to obtain the target motion trajectory based on multiple detection results in the detected video and a target tracking algorithm. The counting and statistics module is used to count and statistically analyze targets whose motion trajectories intersect with the standard line to obtain real-time counting results; wherein, the standard line is a preset horizontal line at the middle position of the channel in the video.
9. A real-time video counting device for livestock in a passageway based on active learning, characterized in that, include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the active learning-based real-time video counting method for livestock in a channel as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it is used to implement the steps of the active learning-based real-time video counting method for livestock in a channel as described in any one of claims 1-7.