A pig identification method, device, equipment and medium

By using Yolov model and motion model to identify and track pigs in pig farms, the problem of complex environment resulting in low recognition accuracy is solved, and efficient pig management and identification is achieved.

CN119763155APending Publication Date: 2025-04-04CHONGQING XIAOFU NONGKANG AGRI TECH SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411879261.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The complex environment of the pig farm has led to too many irrelevant factors in the video, affecting the accuracy of pig recognition, and the requirements for recognition accuracy after the development of computer technology are getting higher and higher.

Method used

The preset Yolov model is used to detect the pig type and position of the images in the identified video, and the preset motion model is used to determine the pig's movement trajectory, and real-time tracking is carried out to trigger the corresponding pig entry or departure operation, update the pig population, and transmit the data to cloud services.

Benefits of technology

It improves the accuracy of pig identification, enhances the efficiency of pig management, and meets high-demand identification accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763155A_ABST
    Figure CN119763155A_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and medium for pig identification, which relates to the field of image processing technology, including: using a preset Yolov model to detect the type and position of each pig corresponding to the image to be identified, and determining the identifier corresponding to each pig; using a preset motion model and based on the pig's position to determine the pig's motion trajectory, and tracking the pig in real time based on the motion trajectory and the identifier to obtain the real-time trajectory; if the real-time trajectory of the pig and the preset pig departure line meet the first preset trigger condition, then trigger the operation of updating the number of pigs leaving, if the real-time trajectory of the pig and the preset pig entry line meet the second preset trigger condition, then trigger the operation of updating the number of pigs entering; the pig type, pig image and the target number of pigs determined based on the number of pigs leaving and the number of pigs entering are transmitted to the preset cloud service. This can improve the accuracy of pig identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a pig identification method, device, equipment and medium. Background Art

[0002] At present, due to the complex environment of pig farms, there are too many irrelevant factors in the uploaded videos, which affects the accuracy of pig identification. In addition, with the rapid development of computer technology, the requirements for pig identification accuracy in actual application scenarios are getting higher and higher.

[0003] As can be seen from the above, how to improve the accuracy of pig identification during the pig identification process is a problem that needs to be solved urgently. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a pig identification method, device, equipment and medium, which can improve the accuracy of pig identification and thus improve the efficiency of pig management. The specific scheme is as follows:

[0005] In a first aspect, the present application provides a pig identification method, which is applied to a preset camera, comprising:

[0006] Obtain a video to be identified corresponding to the target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified;

[0007] Determine the motion trajectory of the pig to be identified by using a preset motion model and based on the position of the pig, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory;

[0008] If the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, the operation of updating the number of pigs entering is triggered;

[0009] The target number of pigs is determined based on the number of pigs leaving and the number of pigs entering, and the target number of pigs and the pig type and pig image corresponding to each pig to be identified are transmitted to a preset cloud service.

[0010] Optionally, the detecting of the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified by using a preset Yolov model includes:

[0011] Using a preset Yolov model, the pigs to be identified corresponding to the plurality of images to be identified in the video to be identified are detected to obtain the pig type, pig position, and skin condition corresponding to the pigs to be identified;

[0012] Determine whether the skin condition corresponding to the pig to be identified meets the preset health conditions. If the skin condition corresponding to the pig to be identified does not meet the preset health conditions, generate corresponding alarm information, and send the alarm information to the preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified; the alarm information includes the identifier corresponding to the pig to be identified, the pig type, the pig image and the skin condition.

[0013] Optionally, the step of acquiring a video to be identified corresponding to a target identification area, and using a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, includes:

[0014] Setting image quality assessment criteria based on user needs; the image quality assessment criteria include image clarity, pig image integrity, and lighting uniformity;

[0015] Acquire a video to be identified corresponding to the target identification area, and screen a number of images to be processed in the video to be identified based on the image quality evaluation standard to obtain a number of images to be identified;

[0016] The preset Yolov model is used to detect the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified.

[0017] Optionally, before using a preset Yolov model to detect the type and position of each of the pigs to be identified in the plurality of images to be identified in the video to be identified, the method further includes:

[0018] Acquire a number of historical pig images including different pig breeds, pig ages, pig body shapes, and pig postures; each of the historical pig images includes different lighting conditions, background environments, and pig shooting angles;

[0019] The historical pig images are labeled with pig positions and pig types to obtain a data set to be trained, and the initial Yolov model is trained using the data set to be trained to obtain the preset Yolov model.

[0020] Optionally, the detecting of the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified by using a preset Yolov model includes:

[0021] Based on a preset data association algorithm, similarity association calculation is performed on each of the pigs to be identified in the plurality of image frames to be identified to obtain a plurality of similarity association results;

[0022] The pigs to be identified in the plurality of image frames to be identified are determined based on the similarity association results, and the pig types and pig positions corresponding to the pigs to be identified are determined using a preset Yolov model.

[0023] Optionally, if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then before the operation of updating the number of pigs entering is triggered, it also includes:

[0024] Based on the path of the pigs entering the pig house, the entry line of the pigs to be processed located in the target identification area is determined, and based on the exit of the pig house and the regional boundary of the pig house passage, the exit line of the pigs to be processed is determined; the path of the pigs entering the pig house includes the location of the pig house entrance, the direction of the pig house passage and the flow direction of the pigs;

[0025] Based on the body shape characteristics of each pig to be identified, the height and width of the entry line for the pigs to be processed and the exit line for the pigs to be processed are adjusted to determine the preset pig exit line and the preset pig entry line.

[0026] Optionally, after adjusting the height and width of the entry line for the pigs to be processed and the exit line for the pigs to be processed respectively based on the body shape characteristics of each pig to be identified, the method further includes:

[0027] A one-way trigger mechanism is established, and the one-way trigger mechanism is used to perform one-way trigger processing operations on the pig entry line to be processed and the pig exit line to be processed, so as to obtain the one-way triggered preset pig exit line and the preset pig entry line.

[0028] In a second aspect, the present application provides a pig identification device, which is applied to a preset camera, comprising:

[0029] A video acquisition module is used to acquire a video to be identified corresponding to a target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified;

[0030] A motion trajectory determination module, used to determine the motion trajectory of the pig to be identified based on the position of the pig using a preset motion model, and to track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory;

[0031] An operation trigger module, configured to trigger an operation of updating the number of pigs leaving if the real-time trajectory of the pigs to be identified and a preset pigs leaving line meet a first preset trigger condition, and trigger an operation of updating the number of pigs entering if the real-time trajectory of the pigs to be identified and a preset pigs entering line meet a second preset trigger condition;

[0032] The information transmission module is used to determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the pig type and pig image corresponding to each pig to be identified to a preset cloud service.

[0033] In a third aspect, the present application provides an electronic device, including:

[0034] Memory, used to store computer programs;

[0035] The processor is used to execute the computer program to implement the aforementioned pig identification method.

[0036] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned pig identification method when executed by a processor.

[0037] As can be seen from the above, before performing pig identification, the present application needs to obtain a video to be identified corresponding to the target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified in several images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified; use a preset motion model and determine the motion trajectory of the pig to be identified based on the pig position, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then trigger the operation of updating the number of pigs leaving, if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then trigger the operation of updating the number of pigs entering; determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the pig type and pig image corresponding to each pig to be identified to the preset cloud service. It can be seen that the present application obtains the video to be identified, and uses the preset Yolov model to detect the type and position of each pig to be identified in several images to be identified in the video to be identified, and determines the identifier corresponding to each pig to be identified; then, the motion trajectory of the pig to be identified is determined by using the preset motion model, and the pig to be identified is tracked in real time based on the motion trajectory and the identifier to obtain the real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then the operation of updating the number of pigs entering is triggered; the target number of pigs is determined based on the number of pigs leaving and the number of pigs entering, and the target number of pigs and the pig type and pig image corresponding to each pig to be identified are transmitted to the preset cloud service. In this way, the accuracy of pig identification is improved, and the efficiency of pig management is improved, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0039] Figure 1 A flow chart of a pig identification method disclosed in this application;

[0040] Figure 2 A schematic diagram of the hardware structure of a camera disclosed in this application;

[0041] Figure 3 A schematic diagram of functional hardware on a specific CPU mainboard disclosed in this application;

[0042] Figure 4 A schematic diagram of installing a preset camera at the top of a pig house passage;

[0043] Figure 5 A specific pig identification method flow chart disclosed in this application;

[0044] Figure 6 This is a schematic diagram of the structure of a pig identification device disclosed in this application;

[0045] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] At present, due to the complex environment of pig farms, there are too many irrelevant factors in the uploaded video, which affects the accuracy of pig identification. In addition, with the rapid development of computer technology, the requirements for the accuracy of pig identification in actual application scenarios are getting higher and higher. To this end, the present application provides a pig identification method that can improve the accuracy of pig identification.

[0048] See also Figure 1 As shown, an embodiment of the present invention discloses a pig identification method, which is applied to a preset camera, comprising:

[0049] Step S11, obtaining a video to be identified corresponding to the target identification area, and using a preset Yolov model to detect the type and position of each pig to be identified corresponding to a number of images to be identified in the video to be identified, and determining an identifier corresponding to each pig to be identified.

[0050] In this embodiment, the preset camera can be a barrel-type surveillance camera or a box-type surveillance camera, and the hardware components are as follows: Figure 2 As shown: The preset camera consists of a Camera module, a communication module, and a CPU (Central Processing Unit) motherboard, and the functional hardware diagram on the CPU motherboard is as follows Figure 3As shown: it contains edge computing processor, memory chip, flash memory chip, 5G (5th generation mobile networks) transmission module, high-efficiency infrared lamp, anti-glare cover, ICR (Image Character Recognition) infrared filter, 2-way relay output interface and voice speaker output interface and other functional hardware, and has a dustproof, waterproof and anti-corrosion functional shell and anti-glare cover.

[0051] It is worth mentioning that the embodiment of the present application can send the analyzed video image frames with pigs and the calculated number and type of pigs to the designated cloud server through the 5G transmission module. In addition, the preset camera has infrared night vision function and dustproof, waterproof and anti-corrosion function, which can adapt to the complex environment of the pig farm. It uses two sets of independent parameters for configuration during the day and night respectively, and supports automatic switching of ICR infrared filter to achieve day and night monitoring. In one specific implementation, the irradiation distance of the high-efficiency infrared lamp can reach 30m, and smartIR (Smart Infrared) is supported to prevent infrared overexposure at night. In another specific implementation, 3D (Three Dimensions) digital noise reduction is supported, 120dB (Decibel) ultra-wide dynamic is supported, corridor mode, backlight compensation, and automatic electronic shutter function are supported to adapt to different monitoring environments.

[0052] When processing video image frames, it supports low bit rate, ROI (Region of Interest) enhanced coding, SVC (Scalable Video Coding) adaptive coding technology, Smart265 coding, and bit stream smoothing settings to meet different requirements for image quality and fluency in different scenarios. In addition, the embodiment of the present application also supports GBK (GuoBiao Kuozhan, i.e. national standard extension) fonts and supports OSD (On-Screen Display, i.e. screen menu adjustment mode) color selection.

[0053] It is worth mentioning that the external data input of the preset camera supports 2-way relay output to control external devices. At the same time, it also supports voice speaker output. In a specific implementation, an external speaker with a power of 20 watts and an impedance of 8 ohms can be connected, and the image resolution can reach 1920×1080@25fps.

[0054] Furthermore, after the preset camera is set up with the function module, the preset camera needs to be installed at the top of the pig house passage, such as Figure 4As shown. It is worth mentioning that it is necessary to ensure that the visual range of the camera can completely cover the entire pig house passage, and there must be no blind spots in the monitoring. The installation height of the camera must ensure that the passage scene can be clearly and completely monitored to prevent pigs from escaping the monitoring field of view, thereby preventing the pig identification results from being inconsistent with the identification scene or the actual number of pigs, thereby improving the accuracy of pig identification. For example, preset cameras can be installed at the pig farm’s pig loading exit and the slaughterhouse’s pig entrance to achieve full monitoring of pigs and ensure the fairness and security of transactions.

[0055] In this embodiment, since the Yolov model is an advanced target detection algorithm with the characteristics of fast detection speed and high accuracy, and the underlying logic is based on a deep neural network, it can directly predict the category and location information of the pig to be identified from the image. For pig identification scenarios, the detection of multiple pigs can also be processed simultaneously to meet real-time requirements. It is worth mentioning that when the Yolov model detects the pigs, a unique identifier is assigned to each pig, so that in subsequent image frames, the pigs can be continuously tracked by predicting their movement trajectories and matching newly detected targets with existing identifiers.

[0056] Furthermore, before using the Yolov model to identify pigs, a training data set needs to be constructed, that is, a large number of pig images containing different pig breeds, pig ages, pig body shapes and pig postures are collected. The above images cover various lighting conditions and background environments, such as different pig house layouts, ground materials, and pig states, such as standing, lying and eating, different shooting angles, etc., and then the images are annotated, wherein the annotation information includes the position of the pig, such as the bounding box coordinates of the pig, and the pig category. After the training data set is constructed, the embodiment of the present application needs to use the constructed data set to train the initial Yolov model. Specifically, before using the preset Yolov model to detect the type and position of each pig to be identified in the several images to be identified in the video to be identified, it can also include: obtaining several historical pig images containing different pig breeds, pig ages, pig body shapes and pig postures; each historical pig image includes different lighting conditions, background environments and pig shooting angles; each historical pig image is annotated with the pig position and pig type to obtain a training data set, and the initial Yolov model is trained using the training data set to obtain a preset Yolov model. During the training process, the results output after each training of the model are compared with the actual annotation information to adjust the parameters of the model. Among them, the parameters of the model include the number of network layers, the size of the convolution kernel and the learning rate to improve the recognition accuracy of the model for pig features. At the same time, data enhancement techniques are used, such as rotating, flipping and scaling the pig images to increase the diversity of the training data and prevent the model from overfitting.

[0057] In this embodiment, after obtaining the Yolov model, the original image acquired by the camera needs to be preprocessed, including normalization and denoising of the image, wherein the normalization operation can map the image pixel value to a specific interval to improve the model training and the recognition effect of the pig; the denoising operation is to remove interference factors in the image, such as spots caused by light reflection or sensor noise. Subsequently, the preprocessed image is input into the trained Yolov model, and the trained Yolov model automatically extracts the features of the pigs, such as the outline, color, and texture of the pigs through a convolutional neural network. Finally, the Yolov model determines whether there are pigs in the image based on the extracted features, and determines the position and category of the pigs. Specifically, using the preset Yolov model to detect the type and position of the pigs corresponding to the several images to be identified in the video to be identified can include: using the preset Yolov model to detect the corresponding pigs to be identified in the several images to be identified in the video to be identified, so as to obtain the type of pigs, pig positions, and skin conditions corresponding to the pigs to be identified.

[0058] In this embodiment, the push method of RTSP (Real-Time Streaming Protocol) is used. By using the RTSP method, the image pictures collected by the preset camera can be efficiently and stably pushed to the streaming media server in the form of video streams. At the same time, in order to ensure the security and traceability of the data, the embodiment of the present application stores and backs up the video stream data in the local system. In a specific implementation, the storage backup strategy corresponding to the local system is to retain the video stream data for 7 days, which takes into account the needs of daily data query and analysis, and avoids the waste of storage resources caused by long-term storage of large amounts of data, ensuring the rational use of storage resources and the optimization of overall performance.

[0059] In this embodiment, in order to further improve the accuracy of pig identification, it is necessary to define an image quality evaluation standard, wherein the factors considered in the image quality evaluation standard include image clarity, pig integrity, that is, whether the pig is displayed in the image completely, whether there is any blocked part, and illumination uniformity. Based on the above standards, the best shot is selected from the image sequence of the entire tracking process. Specifically, the video to be identified corresponding to the target identification area is obtained, and the preset Yolov model is used to detect the type and position of each pig to be identified in the several images to be identified in the video to be identified. It can include: setting an image quality evaluation standard based on user needs; the image quality evaluation standard includes image clarity, pig image integrity and illumination uniformity; obtaining the video to be identified corresponding to the target identification area, and screening the several images to be processed in the video to be identified based on the image quality evaluation standard to obtain several images to be identified; using the preset Yolov model to detect the type and position of each pig to be identified in the several images to be identified in the video to be identified.

[0060] In this embodiment, when detecting the pigs in each frame of the image, it is necessary to use a preset data association algorithm to associate the newly detected pigs with the previously tracked pigs, that is, by using the preset data association algorithm to calculate the similarity between the targets, such as the position and appearance feature similarity, to determine whether the pigs are the same target. Specifically, using a preset Yolov model to detect the type and position of each pig to be identified in a number of images to be identified in the video to be identified can include: performing similarity association calculations on each pig to be identified in a number of image frames to be identified based on a preset data association algorithm to obtain a number of similarity association results; determining each pig to be identified in a number of image frames to be identified based on each similarity association result, and using a preset Yolov model to determine the pig type and pig position corresponding to each pig to be identified. Among them, the preset data association algorithm is the Hungarian algorithm. It is worth mentioning that any algorithm that can associate the newly detected pigs with the previously tracked pigs can be the preset data association algorithm, and they are not limited one by one here.

[0061] In the present embodiment, the performance of the Yolov model and the tracking algorithm needs to be optimized in time to reduce the complexity of the calculation and improve the processing speed of the image. In a specific implementation, a model compression technology can be used to reduce the model size without losing too much precision, and speed up the model loading and reasoning speed. At the same time, the tracking algorithm is parallelized, and the computing power of a multi-core processor or GPU is used to improve the ability of the system to process in real time. In addition, the embodiment of the present application needs to reasonably allocate the camera, processor and memory hardware resources. For example, the frame rate and resolution of the camera are dynamically adjusted according to the density and activity of the pigs in the pig house, and the amount of data and the amount of calculation are reduced under the premise of ensuring the recognition accuracy. For memory management, a cache mechanism is used to reduce frequent data reading and writing operations and improve the overall operation efficiency of the system.

[0062] Step S12: using a preset motion model and based on the position of the pig, determining the motion trajectory of the pig to be identified, and tracking the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory.

[0063] In this embodiment, a motion model is established based on the movement characteristics of the pigs. In the process of establishing the motion model, the common movement patterns of the pigs in the pig house, such as walking, running, turning, etc., need to be considered. The motion model can predict the possible position of the pig in the next frame of the image, reduce the search space for tracking, and improve the tracking efficiency. That is, after obtaining the data association results, the embodiment of the present application needs to update the tracking status of each pig based on the data association results, including position, speed and direction information. In a specific embodiment, if a pig loses tracking in several consecutive frames, such as being blocked by other pigs or exceeding the field of view of the camera, the embodiment of the present application needs to try to retrieve the pig's track based on the motion model and historical information. If the time for trying to retrieve is greater than the preset threshold, it is determined that the pig has left the recognition range.

[0064] In this embodiment, a preset pig departure line and a preset pig entry line need to be set in the recognition area corresponding to the preset camera. For the setting of the preset pig entry line, the embodiment of the present application needs to be determined based on the path that the pigs mainly enter the pig house, that is, the embodiment of the present application needs to consider the entrance position of the pig house, the direction of the passage, and the flow direction of the pigs, to ensure that the preset pig entry line and the normal entry route of the pigs can effectively intersect. Correspondingly, for the setting of the preset pig departure line, the embodiment of the present application needs to set the preset pig departure line for the specific area where the pigs leave based on the pig house exit and the regional boundary. At the same time, the embodiment of the present application needs to adjust the height and width of the preset pig departure line and the preset pig entry line in combination with the body shape characteristics of the target pigs, so as to ensure that the pigs can accurately trigger the preset pig departure line and the preset pig entry line, and reduce misjudgment. Specifically, if the real-time trajectory of the pigs to be identified and the preset pig departure line meet the first preset trigger condition, the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pigs to be identified and the preset pig entry line meet the second preset trigger condition, before the operation of updating the number of pigs entering is triggered, it may also include: determining the entry line of the pigs to be processed located in the target identification area based on the path of the pigs entering the pig house, and determining the departure line of the pigs to be processed based on the exit of the pig house and the regional boundary of the pig house passage; the path of the pigs entering the pig house includes the pig house entrance position, the direction of the pig house passage and the flow direction of the pigs; based on the body shape characteristics of each pig to be identified, the height and width corresponding to the entry line of the pigs to be processed and the departure line of the pigs to be processed are adjusted to determine the preset pig departure line and the preset pig entry line.

[0065] In this embodiment, when the pigs enter the camera recognition range until they leave the camera recognition range, the embodiment of the present application continuously tracks the pigs through the tracking algorithm. When the pigs completely leave the detection range, the number of pigs tracked during the whole process is counted as the number of pigs in this scene.

[0066] It is worth mentioning that in order to avoid false triggering caused by short stays or return of pigs, an appropriate delay judgment mechanism can be set. By reasonably setting the preset pig departure line and the preset pig entry line for one-way triggering, the entry and exit behavior of pigs in the monitoring area can be accurately captured, providing a reliable basis for subsequent monitoring and analysis. That is, when the pig passes through the preset pig departure line and the preset pig entry line, the preset pig departure line and the preset pig entry line can only be successfully triggered when the direction corresponding to the pig's movement trajectory is the preset direction. Specifically, after adjusting the height and width of the processing pig entry line and the processing pig departure line respectively based on the body shape characteristics of each pig to be identified, it also includes: establishing a one-way trigger mechanism, and using the one-way trigger mechanism to perform one-way trigger processing operations on the processing pig entry line and the processing pig departure line to obtain the one-way triggered preset pig departure line and the preset pig entry line. In a specific implementation, when the pig moves from the left side of the preset pig departure line to the right side of the pig, the preset pig departure line can be successfully triggered, and when the pig moves from the right side of the preset pig departure line to the left side of the pig, the preset pig departure line cannot be triggered. In actual operation, the embodiment of the present application can adjust and optimize the preset pig departure line and the preset pig entry line through a visual interface to adapt to different breeding environments and pig activity patterns.

[0067] Step S13: If the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, the operation of updating the number of pigs entering is triggered.

[0068] In this embodiment, in order to adapt to the situation that pigs frequently enter and exit the recognition scene of the preset camera, the embodiment of the present application can set a preset time window. Within the time range corresponding to the preset time window, the number of pigs entering the scene corresponding to the recognition area and the number of pigs leaving the scene corresponding to the recognition area are dynamically updated to obtain accurate real-time pig quantity information.

[0069] Step S14, determining the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmitting the target number of pigs and the pig types and pig images corresponding to each pig to be identified to a preset cloud service.

[0070] In this embodiment, after using the preset Yolov model to detect each pig to be identified corresponding to several images to be identified in the video to be identified to obtain the skin condition corresponding to the pig to be identified, the embodiment of the present application needs to determine whether the skin condition corresponding to the pig to be identified meets the preset health conditions. If the skin condition corresponding to the pig to be identified does not meet the preset health conditions, a corresponding alarm message is generated and sent to the preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified; the alarm information includes an identifier corresponding to the pig to be identified, a pig type, a pig image and a skin condition.

[0071] Furthermore, the embodiments of the present application need to design a fault detection mechanism in the system to utilize the fault detection mechanism to monitor in real time the operating status of the hardware devices, such as camera failure, network connection interruption, and the operating status of the software modules, such as model crash, algorithm anomaly. When a fault is detected using the fault detection mechanism, the system can automatically attempt to recover, such as restarting the relevant software module, reconnecting to the network, or switching to a backup camera. In addition, in order to prevent data loss, the embodiments of the present application establish a data backup mechanism in both the local device and the cloud. In one specific embodiment, the local device can use a temporary storage buffer to temporarily save data when data push to the cloud fails, and re-push the saved data after the network is restored. In another specific embodiment, cloud storage can use data redundancy technology, such as copying data to multiple storage nodes, so that when a storage node fails, the data is still available.

[0072] As can be seen from the above, before the pig identification is performed, the embodiment of the present application needs to obtain the video to be identified corresponding to the target identification area, and use the preset Yolov model to detect the type and position of each pig to be identified in the several images to be identified in the video to be identified, and determine the identifier corresponding to each pig to be identified; use the preset motion model and determine the motion trajectory of the pig to be identified based on the pig position, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain the real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then trigger the operation of updating the number of pigs leaving, if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then trigger the operation of updating the number of pigs entering; determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the type of pigs corresponding to each pig to be identified and the pig image to the preset cloud service. In this way, the accuracy of pig identification is improved, thereby improving the efficiency of pig management.

[0073] For further information, see Figure 5 As shown, an embodiment of the present invention discloses a pig identification method, which is applied to a preset camera, comprising:

[0074] First, configure the AI ​​(Artificial Intelligence) smart recognition terminal in the preset camera to identify and dynamically track pigs when they enter the recognition area of ​​the preset camera.

[0075] Secondly, when it is detected that the pig's movement trajectory triggers the preset pig leaving line, the time corresponding to the time when the pig triggers the preset pig leaving line is recorded, and the number of pigs leaving is updated, that is, the number of pigs leaving is increased by one: Cout=Cout+1; if it is detected that the pig's movement trajectory has not triggered the preset pig leaving line, the pig will continue to be dynamically tracked.

[0076] Then, the pigs in the video image are continuously tracked dynamically. When the pig's movement trajectory is detected to trigger the preset pig entry line, the time corresponding to when the pig triggers the preset pig entry line is recorded, and the number of pigs entering is updated, that is, the number of pigs entering is increased by one: Cinto=Cinto+1; if the pig's movement trajectory is detected to have not yet triggered the preset pig entry line, the pigs are continuously tracked dynamically.

[0077] Then, after the pigs in each video image in the video to be identified are identified, the current number of pigs is determined based on the number of pigs entering and the number of pigs leaving. In a specific implementation, if the pigs uniformly leave the pig house in the time period corresponding to the video to be identified, the current number of pigs is the difference between the number of pigs leaving and the number of pigs entering; if new pigs enter the pig house in the time period corresponding to the video to be identified, the current number of pigs is the difference between the number of pigs entering and the number of pigs leaving. That is, the current number of pigs is the absolute value of the difference between the number of pigs entering and the number of pigs leaving. Then, the current number of pigs and the pig pictures are uploaded to the preset cloud service through the API port of the cloud service.

[0078] It is worth mentioning that the embodiment of the present application needs to identify the skin condition of the pig while dynamically tracking the pig. After obtaining the skin condition corresponding to the pig to be identified, the embodiment of the present application needs to determine whether the skin condition corresponding to the pig to be identified meets the preset health conditions. Among them, the preset health condition is that the pig has no skin disease and epidermal damage. If the skin condition corresponding to the pig to be identified does not meet the preset health conditions, a corresponding alarm message is generated, and the alarm message is sent to the preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified; the alarm information includes the identifier corresponding to the pig to be identified, the pig type, the pig image and the skin condition.

[0079] As can be seen from the above, before the pig identification is performed, the embodiment of the present application needs to obtain the video to be identified corresponding to the target identification area, and use the preset Yolov model to detect the type and position of each pig to be identified in the several images to be identified in the video to be identified, and determine the identifier corresponding to each pig to be identified; use the preset motion model and determine the motion trajectory of the pig to be identified based on the pig position, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain the real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then trigger the operation of updating the number of pigs leaving, if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then trigger the operation of updating the number of pigs entering; determine the target number of pigs based on the number of pigs leaving and the number of pigs entering. At the same time, the skin condition of the pig is identified, and it is determined whether the skin condition corresponding to the pig to be identified meets the preset health condition. If the skin condition of the pig to be identified does not meet the preset health conditions, a corresponding alarm message will be generated and sent to the preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified. In this way, the accuracy of pig identification is improved, thereby improving the efficiency of pig management.

[0080] Accordingly, see Figure 6 As shown, the present application also provides a pig identification device, which is applied to a preset camera, comprising:

[0081] The video acquisition module 11 is used to acquire a video to be identified corresponding to a target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified;

[0082] A motion trajectory determination module 12, for determining the motion trajectory of the pig to be identified based on the position of the pig using a preset motion model, and tracking the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory;

[0083] The operation trigger module 13 is used to trigger the operation of updating the number of pigs leaving if the real-time trajectory of the pigs to be identified and the preset pigs leaving line meet the first preset trigger condition, and to trigger the operation of updating the number of pigs entering if the real-time trajectory of the pigs to be identified and the preset pigs entering line meet the second preset trigger condition;

[0084] The information transmission module 14 is used to determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the pig type and pig image corresponding to each pig to be identified to a preset cloud service.

[0085] As can be seen from the above, before performing pig identification, the embodiment of the present application needs to obtain a video to be identified corresponding to the target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified in several images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified; use a preset motion model and determine the motion trajectory of the pig to be identified based on the pig position, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then trigger the operation of updating the number of pigs leaving, if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then trigger the operation of updating the number of pigs entering; determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the pig type and pig image corresponding to each pig to be identified to the preset cloud service. It can be seen that the present application obtains the video to be identified, and uses the preset Yolov model to detect the type and position of each pig to be identified in several images to be identified in the video to be identified, and determines the identifier corresponding to each pig to be identified; then, the motion trajectory of the pig to be identified is determined by using the preset motion model, and the pig to be identified is tracked in real time based on the motion trajectory and the identifier to obtain the real-time trajectory; if the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then the operation of updating the number of pigs entering is triggered; the target number of pigs is determined based on the number of pigs leaving and the number of pigs entering, and the target number of pigs and the pig type and pig image corresponding to each pig to be identified are transmitted to the preset cloud service. In this way, the accuracy of pig identification is improved, thereby improving the efficiency of pig management.

[0086] In some specific implementations, the video acquisition module 11 may specifically include:

[0087] A pig detection unit, used for detecting each of the pigs to be identified corresponding to the plurality of images to be identified in the video to be identified by using a preset Yolov model, so as to obtain the pig type, pig position, and skin condition corresponding to the pig to be identified;

[0088] The skin condition judgment unit is used to judge whether the skin condition corresponding to the pig to be identified meets the preset health conditions. If the skin condition corresponding to the pig to be identified does not meet the preset health conditions, a corresponding alarm message is generated, and the alarm message is sent to a preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified; the alarm message includes an identifier corresponding to the pig to be identified, a pig type, a pig image and a skin condition.

[0089] In some specific implementations, the video acquisition module 11 may specifically include:

[0090] An evaluation standard setting unit, used to set image quality evaluation standards based on user requirements; the image quality evaluation standards include image clarity, pig image integrity, and illumination uniformity;

[0091] An image screening unit, used for acquiring a video to be identified corresponding to a target identification area, and screening a plurality of images to be processed in the video to be identified based on the image quality evaluation standard to obtain a plurality of images to be identified;

[0092] The pig detection unit is used to detect the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified by using a preset Yolov model.

[0093] In some specific embodiments, the pig identification device may further include:

[0094] A historical image acquisition unit, used to acquire a number of historical pig images including different pig breeds, pig ages, pig body shapes and pig postures; each of the historical pig images includes different lighting conditions, background environments and pig shooting angles;

[0095] The image annotation unit is used to annotate the position and type of the pigs in each of the historical pig images to obtain a data set to be trained, and to train an initial Yolov model using the data set to be trained to obtain the preset Yolov model.

[0096] In some specific implementations, the video acquisition module 11 may specifically include:

[0097] An association calculation unit, used for performing similarity association calculation on each of the pigs to be identified in the plurality of image frames to be identified based on a preset data association algorithm, so as to obtain a plurality of similarity association results;

[0098] The pig determination unit is used to determine each of the pigs to be identified in the plurality of image frames to be identified based on each of the similarity association results, and to determine the pig type and pig position corresponding to each of the pigs to be identified by using a preset Yolov model.

[0099] In some specific embodiments, the pig identification device may further include:

[0100] A pig entry line determination unit is used to determine the pig entry line to be processed located in the target identification area based on the path of the pigs entering the pig house, and determine the pig exit line to be processed based on the exit of the pig house and the regional boundary of the pig house passage; the pig entry path includes the pig house entrance position, the direction of the pig house passage and the flow direction of the pigs;

[0101] The pig entry line adjustment unit is used to adjust the height and width of the pig entry line to be processed and the pig exit line to be processed respectively based on the body shape characteristics of each pig to be identified, so as to determine the preset pig exit line and the preset pig entry line.

[0102] In some specific embodiments, the pig identification device may further include:

[0103] The one-way trigger mechanism establishing unit is used to establish the one-way trigger mechanism, and use the one-way trigger mechanism to perform one-way trigger processing operations on the pig entry line to be processed and the pig departure line to be processed, so as to obtain the one-way triggered preset pig departure line and the preset pig entry line.

[0104] Furthermore, the present application also discloses an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the pig identification method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0105] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0106] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0107] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the pig identification method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.

[0108] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned pig identification method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.

[0109] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0110] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0111] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0112] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0113] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for identifying pigs, characterized in that: Applies to preset cameras, including: Obtain a video to be identified corresponding to the target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified; Determine the motion trajectory of the pig to be identified by using a preset motion model and based on the position of the pig, and track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory; If the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, the operation of updating the number of pigs entering is triggered; The target number of pigs is determined based on the number of pigs leaving and the number of pigs entering, and the target number of pigs and the pig type and pig image corresponding to each pig to be identified are transmitted to a preset cloud service.

2. The pig identification method according to claim 1, characterized in that: The detecting of the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified by using a preset Yolov model includes: Using a preset Yolov model, the pigs to be identified corresponding to the plurality of images to be identified in the video to be identified are detected to obtain the pig type, pig position, and skin condition corresponding to the pig to be identified; Determine whether the skin condition corresponding to the pig to be identified meets the preset health conditions. If the skin condition corresponding to the pig to be identified does not meet the preset health conditions, generate corresponding alarm information, and send the alarm information to the preset cloud service so that relevant personnel can perform health recovery operations on the pig to be identified; the alarm information includes the identifier corresponding to the pig to be identified, the pig type, the pig image and the skin condition.

3. The pig identification method according to claim 1, characterized in that: The step of acquiring a video to be identified corresponding to the target identification area, and using a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, includes: Setting image quality assessment criteria based on user needs; the image quality assessment criteria include image clarity, pig image integrity, and lighting uniformity; Acquire a video to be identified corresponding to the target identification area, and screen a number of images to be processed in the video to be identified based on the image quality evaluation standard to obtain a number of images to be identified; The preset Yolov model is used to detect the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified.

4. The pig identification method according to claim 1, characterized in that: Before using the preset Yolov model to detect the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified, the method further includes: Acquire a number of historical pig images including different pig breeds, pig ages, pig body shapes, and pig postures; each of the historical pig images includes different lighting conditions, background environments, and pig shooting angles; The historical pig images are labeled with pig positions and pig types to obtain a data set to be trained, and the initial Yolov model is trained using the data set to be trained to obtain the preset Yolov model.

5. The pig identification method according to claim 1, characterized in that: The detecting of the type and position of each pig to be identified in the plurality of images to be identified in the video to be identified by using the preset Yolov model includes: Based on a preset data association algorithm, similarity association calculation is performed on each of the pigs to be identified in the plurality of image frames to be identified to obtain a plurality of similarity association results; The pigs to be identified in the plurality of image frames to be identified are determined based on the similarity association results, and the pig types and pig positions corresponding to the pigs to be identified are determined using a preset Yolov model.

6. The pig identification method according to any one of claims 1 to 5, characterized in that: If the real-time trajectory of the pig to be identified and the preset pig departure line meet the first preset trigger condition, then the operation of updating the number of pigs leaving is triggered; if the real-time trajectory of the pig to be identified and the preset pig entry line meet the second preset trigger condition, then before the operation of updating the number of pigs entering is triggered, it also includes: Based on the path of the pigs entering the pig house, the entry line of the pigs to be processed located in the target identification area is determined, and based on the exit of the pig house and the regional boundary of the pig house passage, the exit line of the pigs to be processed is determined; the path of the pigs entering the pig house includes the location of the pig house entrance, the direction of the pig house passage and the flow direction of the pigs; Based on the body shape characteristics of each pig to be identified, the height and width of the entry line for the pigs to be processed and the exit line for the pigs to be processed are adjusted to determine the preset pig exit line and the preset pig entry line.

7. The pig identification method according to claim 6, characterized in that: After adjusting the height and width of the entry line for the pigs to be processed and the exit line for the pigs to be processed respectively based on the body shape characteristics of each pig to be identified, the method further includes: A one-way trigger mechanism is established, and the one-way trigger mechanism is used to perform one-way trigger processing operations on the pig entry line to be processed and the pig exit line to be processed, so as to obtain the one-way triggered preset pig exit line and the preset pig entry line.

8. A pig identification device, characterized in that: Applies to preset cameras, including: A video acquisition module is used to acquire a video to be identified corresponding to a target identification area, and use a preset Yolov model to detect the type and position of each pig to be identified corresponding to a plurality of images to be identified in the video to be identified, and determine an identifier corresponding to each pig to be identified; A motion trajectory determination module, used to determine the motion trajectory of the pig to be identified based on the position of the pig using a preset motion model, and to track the pig to be identified in real time based on the motion trajectory and the identifier to obtain a real-time trajectory; An operation trigger module, configured to trigger an operation of updating the number of pigs leaving if the real-time trajectory of the pigs to be identified and a preset pigs leaving line meet a first preset trigger condition, and trigger an operation of updating the number of pigs entering if the real-time trajectory of the pigs to be identified and a preset pigs entering line meet a second preset trigger condition; The information transmission module is used to determine the target number of pigs based on the number of pigs leaving and the number of pigs entering, and transmit the target number of pigs and the pig type and pig image corresponding to each pig to be identified to a preset cloud service.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the pig identification method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the steps of the pig identification method according to any one of claims 1 to 7 are implemented.