Method and system for identifying and tracking pigs based on EMDA
By using high-definition camera equipment and fusion particle filters, dynamic ID allocation algorithms and enhanced matching strategies in pig farms, the problems of opacity and frequent ID changes in online pig transactions are solved, and the uniqueness of pig identity and The accuracy of tracking improves customer experience.
Patent Information
- Application Number
- CN202411245621.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In online pig trading, pig information is not transparent, resulting in fairness issues, and occlusion causes the ID serial number to change too quickly, resulting in the problem of innocence of identity.
Using EMDA-based pig identification and tracking method, by setting up high-definition camera equipment in pig farms, using fusion particle filters for state prediction, combined with dynamic ID allocation algorithm and enhanced matching strategy, ensure the identity of each pig during the tracking process. Uniqueness and continuity.
Effectively control the ID floating range, improves the reliability and accuracy of pig tracking, ensures customer experience and satisfaction, provides an intuitive and detailed pig activity information display interface, and improves customer selection and purchase experience.
Smart Images

Figure CN119131840A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection and tracking, and in particular to an EMDA-based pig identification and tracking method, system and device. Background Art
[0002] Information technology has brought huge development opportunities to the pig industry, greatly improved the information processing capabilities and management efficiency of enterprises, and injected strong impetus into the market transaction model. Under the background of "Internet +", pig trading has gradually shifted from the traditional offline model to the online model. This change allows farmers and slaughtering companies to trade directly, reducing the intermediate links, reducing procurement costs, and reducing price fluctuations. In addition, due to the requirements of the pig growth environment, reducing contact with the outside world, avoiding the vicious incidents of virus infection causing the death of a large number of pigs, and causing huge losses, online pig trading is particularly important.
[0003] Online pig trading is a great benefit to both sellers and buyers. Pigs can be selected on the mobile terminal, and the ID of the required pigs can be submitted after screening their appearance, which greatly improves transaction efficiency and reduces time costs.
[0004] The pig information is not transparent enough to customers during the purchase process, which leads to fairness issues for customers in online sales. In addition, in the process of tracking and detecting pigs, there will be target tracking loss and occlusion problems, which will cause the ID number to change too quickly, causing the ID value to far exceed the actual number of pigs, which will have a certain impact on the customer's selection of pigs.
[0005] After searching, the patent application document with Chinese patent application number 201810404681.6 and application publication date October 12, 2018 discloses a pig farm automation management system and method. The system includes: a pig entry management module: used to weigh the pigs entering the farm through an electronic weighing sensor and calculate the pig cost; a pig feeding management module: used to collect the water, electricity and feed usage during the feeding process and calculate the feeding cost; a pig delivery management module: used to weigh the pigs through an electronic weighing sensor when they are delivered and calculate the pig selling price; a statistical module: used to calculate the pig farm breeding profit through the pig selling price, feeding cost and pig cost. This patent only realizes automated data collection and management, so that the breeder can clearly understand the feeding cost and profit during the feeding process, but does not realize the online sale of pigs and the accurate tracking of pigs. The present invention realizes the online sale of pigs and the accurate tracking of pigs.
[0006] After searching, the patent application document with Chinese patent application number 202310672928.3 and application publication date July 18, 2023 discloses a remote pig selling supervision method, device and equipment based on image recognition. The method includes: obtaining a pig delivery video according to a pig delivery plan, wherein the pig delivery video is obtained by shooting a camera preset in a pig delivery channel; identifying pigs for each frame of the pig delivery video, and predicting key points of the identified pigs through a key point recognition algorithm based on a convolutional neural network to obtain pig key points; analyzing the identified pigs based on the pig key points to obtain pig size and pig weight; counting the pigs in the pig delivery video through a preset multi-segmentation line multiplicity statistical method to obtain the number of pigs; counting the pigs passing through the statistical line based on spatial weight and time weight to obtain the number of pigs; calculating the value on the statistical line according to the source direction of the pig identification frame passing through the statistical line; normalizing the values of all the statistical lines according to time to obtain the number of pigs; and forming a pig delivery record with the obtained pig size, pig weight and pig number. This patent only realizes the recording of pig weight, number and size through image recognition. However, repeated recognition may occur during the re-recognition process, which may cause the statistical number to be inconsistent with the actual number. And it can be seen from the patent diagram that the recognition is done at the top. Recognition at this angle will lead to inaccurate calculation of pig size and weight, and the similar features of the pigs at the top will lead to duplicate recognition and inaccurate counting. The present invention uses an oblique viewing angle so that the tracking recognition algorithm can better identify the pig features.
[0007] Therefore, in order to sell pigs online efficiently and transparently, it is urgent to solve the problems of target loss due to occlusion and non-unique ID. Summary of the invention
[0008] The present invention aims to at least solve the problems in the prior art that the pig information of online pig sales is not transparent enough to customers, and that the ID serial number changes too quickly due to pig obstruction, making the pig ID non-unique.
[0009] To this end, the present invention provides a pig identification and tracking method based on EMDA, which specifically includes the following steps:
[0010] S1. Set up camera equipment at key locations in the pig farm to obtain real-time video streams or offline videos of live pigs;
[0011] S2, use the detector to detect each frame and perform state prediction by fusing particle filters;
[0012] S3, using a dynamic ID allocation algorithm to assign IDs to pig targets;
[0013] S4, use the enhanced matching strategy to rematch the lost target;
[0014] S5. Return the identification and tracking results to the client and enterprise end
[0015] Beneficial Effects
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: the method of the present invention based on the tracking algorithm and applied to the finished pig sales process effectively controls the ID floating range through a dynamic ID allocation algorithm and an enhanced matching strategy, avoids tracking confusion caused by frequent ID switching, and thus ensures the uniqueness and continuity of the identity of each pig in the entire tracking process;
[0017] Secondly, the fusion particle filter combines linear estimation and nonlinear processing capabilities, which can handle nonlinear target tracking problems in complex dynamic environments and improve the reliability and accuracy of pig tracking;
[0018] The system can also acquire and process video streams of pig activities in real time, ensuring the real-time and accuracy of detection and tracking results. It provides users with an intuitive and detailed interface for displaying pig activity information, enabling customers to select and purchase pigs in a personalized manner, thus improving customer experience and satisfaction. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a flow chart of the target tracking of the present invention applied to the finished pig sales process;
[0020] Figure 2 A schematic diagram of a network structure optimized for the target tracking algorithm of the present invention;
[0021] Figure 3 It is a schematic diagram of intelligent management of two ID pools of the present invention;
[0022] Figure 4 The diagram shows the changes before and after occlusion;
[0023] Figure 5 The comparison between not using DA algorithm and using DA algorithm is shown. DETAILED DESCRIPTION
[0024] The embodiments of the present invention are described below in conjunction with the drawings in the embodiments of the present invention. The terms used in the implementation mode of the present invention are only used to explain the specific embodiments of the present invention, and are not intended to limit the present invention. The embodiments of the present application are described below in conjunction with the drawings.
[0025] refer to Figure 1 , which is a method and system for optimizing a tracking algorithm and applying it to a finished pig sales process according to an embodiment of the present invention, comprising the following steps:
[0026] S11. Set up video equipment at key locations in the pig farm to obtain real-time video streams or offline videos of live pigs;
[0027] S12, use the detector to detect each frame and perform state prediction by fusing the particle filter;
[0028] S13, using a dynamic ID allocation algorithm to assign IDs to pig targets;
[0029] S14, use the enhanced matching strategy to rematch the lost target;
[0030] S15. Return the identification and tracking results to the client and the enterprise.
[0031] The specific process of step S11 is as follows:
[0032] Set up video equipment at key locations on the pig farm. First, choose cameras with high definition and night vision functions that can adapt to the pig house environment, such as waterproof, dustproof, and high and low temperature resistant, to ensure that clear video images can be captured under various lighting conditions; determine the installation location of the camera according to the size and layout of the pig house to ensure that all activity areas are covered and blind spots are avoided;
[0033] The camera should be installed in a position where pigs cannot collide with it, usually at a height of 2-3 meters, to provide a good monitoring angle, and fixed with a sturdy bracket to adjust the angle and focal length; the camera equipment is connected to the data center via a wired or wireless network to ensure that the video stream can be transmitted in real time; for wired networks, network cables should be laid to ensure a stable connection; for wireless networks, high-performance wireless access points (APs) should be configured to ensure signal stability and transmission rate;
[0034] Configure the data transmission protocol of the camera equipment, such as any of the RTSP and RTMP protocols, to ensure that the video stream can be transmitted to the data center or cloud server in real time. After the deployment is completed, conduct environmental adaptability tests to ensure that the camera equipment can work normally under different lighting, temperature, and humidity conditions, and the video image is clear; the video data is effectively stored through local or cloud storage devices with sufficient storage capacity and data backup functions. The video management system classifies and archives the data for subsequent processing and analysis.
[0035] like Figure 2 This is the EMDA-DeepSORT algorithm flow, and the specific process of steps S12-S14 is as follows:
[0036] Start the video stream processing module, load the video data, and initialize the parameters of the tracking system, including the target detection model, filter parameters, ID allocation pool, etc. When the system is initialized, it is also necessary to prepare the camera equipment to ensure that the equipment covers the main activity area of the pig house in order to obtain the complete activity video stream of the pigs.
[0037] Perform initial target detection on the video frame and obtain the initial detection results. The detection results include the target's bounding box, category information, and confidence. These detection results will be used in the subsequent tracking process.
[0038] Assign a unique ID to each initially detected target and initialize the target's status information. Use a hash function to calculate the hash value of the detected target and take the modulus to get the initial ID to ensure the uniqueness of the ID.
[0039] new id = (hash (d i )mod N)+1
[0040] Perform target detection on the current frame and obtain the detection results, including the target's bounding box, category information, and confidence. This step is the basis of the entire tracking process and ensures that the target in the current frame can be accurately identified.
[0041] The state of each tracked target is predicted using a fusion particle filter (FPF). FPF combines the linear estimation capability of the Kalman filter with the nonlinear processing capability of the particle filter, and can provide accurate target state prediction in complex dynamic environments. The predicted state formula is as follows:
[0042]
[0043] Calculate the matching score between each detection result in the current frame and each tracked target in the previous frame. The matching score is calculated by weighted summation based on the cosine similarity and Euclidean distance of the target. The matching score formula is as follows:
[0044]
[0045] According to the matching scores, preliminary matching is performed to obtain matched detection results and tracking target pairs, as well as unmatched detection results and tracking targets.
[0046] For the matching targets, update the target status:
[0047] Update the particle's error covariance matrix to reflect the uncertainty in the state estimate:
[0048]
[0049] Perform secondary matching on the unmatched detection results and tracking targets after the initial matching, and set a new matching function. The new matching function combines the Manhattan distance and the Euclidean distance, and calculates the matching score by weighted summation. The secondary matching formula is as follows:
[0050]
[0051] like Figure 3 Intelligent management of IDs. New IDs are assigned to secondary matching detection results and newly detected targets. The dynamic ID allocation algorithm ensures the continuity and stability of ID allocation through an intelligent ID management mechanism, avoiding tracking confusion caused by frequent ID switching. Figure 4 , Figure 5 The changes before and after occlusion are shown, as well as the comparison between not using the DA algorithm and using the DA algorithm. The ID allocation strategy is as follows:
[0052] The system creates two pools during initialization, one for storing lost target IDs (se l f.track_pool) and one for storing allocated IDs
[0053] (se l f.ass i gned ids). First, it checks whether se l f.track_pool is empty. If it is not empty, it directly calls the ID from the pool for allocation. If it is empty, it executes the following strategy:
[0054] Check whether the currently allocated IDs are continuous. If the IDs are continuous and the minimum value is 0, a new ID is allocated, and the new ID is the maximum value of the currently allocated ID plus one. If the IDs are not continuous and the minimum value of the allocated ID is not 0, a new ID of 0 is allocated. If 0 has been allocated, the smallest unallocated ID is selected. The specific method is to find the smallest unallocated ID from the ID pool and assign it to the new target.
[0055] After the new ID is allocated, the ID pool is adjusted dynamically. When the ID is called from se l f.track_pool, the ID is removed from the pool and added to se l f.assigned ids. If the target is lost, the ID of the lost target is added to the se l f.track_pool. When the ID is called from se l f.assigned ids, the ID is removed from the pool.
[0056] The specific process of step S15 is as follows:
[0057] First, the recognition and tracking algorithms in the video stream processing module generate tracking results after processing each video frame. These results include the bounding box coordinates, confidence, category information, and assigned unique ID of each detected target, and package these data into data packets. Transmission is carried out through efficient data transmission protocols (such as HTTP, WebSocket, or MQTT). In order to ensure the security and privacy of the data, the data packets will be encrypted during transmission. After receiving the data packets, the client and enterprise servers perform preliminary unpacking and verification to ensure the integrity and correctness of the data, and store the data in the database; client users view the status information of each detected target in real time through the visual interface, and enterprise managers view and analyze the tracking results through a dedicated management system, providing multiple views and reports for decision support. The system also supports real-time feedback from client users and remote control from the enterprise side to ensure flexible response to various situations.
[0058] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A pig identification and tracking method based on EMDA, characterized in that: The method specifically comprises the following steps: S1. Set up camera equipment at key locations in the pig farm to obtain real-time video streams or offline videos of live pigs; S2, use the detector to detect each frame and perform state prediction by fusing particle filters; S3, using a dynamic ID allocation algorithm to assign IDs to pig targets; S4, use the enhanced matching strategy to rematch the lost target; S5. Return the identification and tracking results to the client and the enterprise.
2. The pig identification and tracking method based on EMDA according to claim 1, characterized in that: In step S1, the specific process of obtaining the real-time video stream is as follows: 1) Choose a camera with a resolution of 1080P or above; 2) According to the layout of the pig house, choose to install the camera equipment at a position 50 to 70 degrees above the horizontal line of the pig house to ensure that the characteristics of the pigs can be captured and all important activity areas are covered; 3) Configure the data transmission protocol in the camera to ensure stable transmission of the video stream; the camera has an automatic reconnection function to prevent video stream interruption caused by network interruption.
3. The pig identification and tracking method based on EMDA according to claim 1 is characterized in that: The data transmission protocol uses RTSP.
4. The pig identification and tracking method based on EMDA according to claim 1 is characterized in that: In step S2, the specific process of pig identification and tracking is as follows: 1) Extract continuous video frames from the real-time video stream to ensure that each frame can clearly capture the activities of the pigs; use a detector to process each frame, identify the pigs in the video frame, and generate a detection value containing position coordinates and classification information; 2) Use the fusion particle filter to predict the state, the specific method is as follows: State initialization: Initialize particle collection In the formula, is the state of the ith particle, is the corresponding particle weight, satisfying State prediction: For each particle Use the state transition model to make predictions: Where f is the state transfer function, u k is the control input, is process noise, satisfying Gaussian distribution Gain calculation: After each particle prediction, calculate the particle gain In the formula, is the error covariance matrix prediction value of the ith particle, H is the observation matrix, R k is the observation noise covariance matrix; State Update: Update the state estimate for each particle: At the same time, the error covariance matrix of the particle is updated: Particle weight update: based on the observed value y k Update particle weights: And normalize it: Resampling: If the particle is degraded, that is, the number of effective particles is lower than the threshold, resampling is performed to avoid particle degradation and calculate the number of effective particles: If N eff <N thresh , then resampling is performed and a new particle set is generated using the resampling method Where N thresh Represents the resampling threshold, which is used to determine whether resampling is needed.
5. The pig identification and tracking method based on EMDA according to claim 1, characterized in that: In step S3, a new ID is allocated using the dynamic ID allocation algorithm DA. The specific process is as follows: 1) Initial ID allocation: Assign a unique initial ID to each newly detected target and initialize the target's status information: new id=(hash(d i )mod N)+1; In the formula, hash(d i ) is the detection target d i The hash value of N is a parameter, and the specific value is 5 to 6 times the number of tracked targets to ensure the uniqueness of the ID; 2) ID continuity check: In each tracking cycle, check whether the currently allocated ID is continuous: is_continuous=max(self.assigned_ids)-min(self.assigned_ids)+1==|en(self.assigned_ids)| 3) ID allocation strategy: Select the appropriate ID allocation strategy based on the ID continuity check result: If the lost target ID pool (self.track_pool) is not empty, pop: if(self.track_pool!= If the IDs are continuous and the minimum value is 0, a new ID is assigned with the maximum value plus one: if(is_continuous and min(self.assigned_ids)==0): new_id=max(self.assigned_ids)+1 If the minimum value of the assigned ID is not 0, a new ID of 0 is assigned: if (min (self.assigned ids) ≠ 0): newid = 0.
6. The pig identification and tracking method based on EMDA according to claim 1, characterized in that: In step S4, the lost target is re-matched, and the specific process is as follows: 1) Initial matching: Calculate the matching score of each detection result in the current frame and each tracked target in the previous frame, and perform preliminary matching: Among them, α, β, γ are adjustment parameters, CosineSimilarity(d i ,t j ) is the test result d i and tracking target t j The cosine similarity between i ,t j ) is the Euclidean distance between the two; 2) Unmatched target set: Determine the set of unmatched detection results D after the initial match u and the unmatched tracking target set T u : D u ={d1,d2,…,d m },T u ={t1,t2,…,t n }; 3) Rematching: Perform secondary matching on the unmatched detection results and unmatched tracking targets, and set a new matching function: Manhattan i ,t j ) is the Manhattan distance between the two. 4) Dynamic ID allocation: For the detection results after re-matching, a new ID is allocated using the dynamic ID allocation algorithm (DA).
7. The pig identification and tracking method based on EMDA according to claim 1 is characterized in that: In step S5, the video tracking results are returned to the client and the enterprise. The specific process is as follows: The video stream push device pushes the tracking results to the client for the customer to select, and can provide the selected pig ID based on the tracking results; The enterprise side can check the real-time status of the pig farm through tracking results, and deliver to customers based on the pig ID provided by the customer.
8. A pig identification and tracking system based on EMDA, characterized in that: The system uses the pig identification and tracking method as described in any one of claims 1 to 7 to identify and track pigs; Specifically include: video stream acquisition device, video stream processing module, user terminal, management module; The shooting device sends the shot video to the video processing module, and the video processing module sends the recognition and tracking results of the video processing to the user terminal for the customer to select pigs and the enterprise end to check the pig house.
Citation Information
Patent Citations
Pig farm automated management system and method
CN108647871A
A method, device, and equipment for remote pig selling supervision based on image recognition.
CN116453061B
