A method for counting animal targets based on dual-light cameras
Through the animal target counting method combined with the dual-optical camera and the YOLOv4 neural network model, the problem of time-consuming and inaccurate inventory of traditional pigs is solved, and accurate counting and automated monitoring in large-scale farms are realized, which improves the data Reliability and traceability.
Patent Information
- Application Number
- CN202111127058.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-26
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-09-26
AI Technical Summary
The traditional pig inventory method is time-consuming and labor-intensive, prone to errors, and is greatly affected by the external light environment, resulting in inaccurate statistics and difficult to meet the accurate data needs of large-scale farms.
An animal target counting method based on a two-light camera is adopted, and the visible and thermal image sample library is constructed, and the YOLOv4 neural network model is used for identification, and the recognition accuracy is improved in combination with the correction model to achieve contactless accurate counting.
More accurate pig inventory has been achieved in large-scale pig farms, reducing manual errors, and improving data reliability and traceability. Especially during the African swine fever prevention and control period, it provides a new direction of automated monitoring and management .
Smart Images

Figure CN113724250B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of breeding, and in particular to an animal target counting method based on a dual-light camera. Background Art
[0002] In the pig breeding process, as far as pig inventory is concerned, from the delivery room to the gestation house, from nursery to market, each stage requires real-time statistics on the number of animals in the pen, so that large-scale farms can track production information and adjust production strategies. However, the traditional operation method is to manually count the number of pigs in the house, which is not only time-consuming and labor-intensive, but also the number of pigs changes every day, with pigs dying and being culled, and pigs being moved to other houses and pens. Manual records are prone to errors.
[0003] In recent years, with the rise of artificial intelligence technology in the breeding industry, more and more companies have begun to use technologies such as the Internet of Things, artificial intelligence, and big data to improve production efficiency. Application scenarios include pig face recognition, disease detection, and pig behavior analysis. Pig inventory is a very valuable task. The commonly used non-contact pig inventory method is a track-mounted robot, which uses a visible light camera to capture the pigs in the pen in real time to record the number. However, there are many problems. For example, the track needs to be planned and laid in advance when the pig farm is built, which poses a huge challenge to the reconstruction plan of the existing farm; the visible light camera is greatly affected by the external light environment, which is easy to cause missed judgment or misjudgment, which has a great impact on the accuracy of the animal count in the pen. The inaccurate animal count will directly affect the final economic benefits.
[0004] Infrared thermal imaging measurement technology has been widely used in military and civilian fields, playing an irreplaceable and important role. Currently, common thermal imaging equipment on the market has high pixel clarity, temperature measurement error of ±0.5℃, and can realize target detection and counting functions. At present, there is an urgent need for a highly reliable animal counting method to obtain real, reliable, and traceable data to meet the application in conventional production scenarios. Summary of the invention
[0005] In order to more accurately count the animals in the enclosure, the present invention provides an animal target counting method based on a dual-light camera.
[0006] In order to achieve the above-mentioned object of the invention, the present invention provides an animal target counting method based on a dual-light camera, the method comprising the following steps:
[0007] Step S1: Obtain animal stall images to construct a sample library, with stall images with animal faces as positive samples and stall images without animal faces as negative samples;
[0008] Step S2: constructing a counting model, wherein the counting model includes a neural network model for animal identification;
[0009] Step S3: input the sample library into the neural network model for training to obtain a trained neural network model;
[0010] Step S4: sequentially acquiring the images to be tested of each column, each column corresponds to a group of images to be tested, and each group of images to be tested includes n images to be tested;
[0011] Step S5: input the 2n images to be tested corresponding to each pen into the constructed counting model in turn, obtain the final recognition result of each pen, and count the final recognition results of all pen to obtain the number of animal targets.
[0012] The counting model further includes a correction model connected to the back end of the neural network model, and the correction model is used to correct the recognition result of each pen and count the final recognition results of all pen to obtain the number of animal targets;
[0013] The sample library obtained in step S1 includes two sub-sample libraries, namely a visible light image sample library and a thermal imaging image sample library;
[0014] The image group to be tested corresponding to each column obtained in step S4 includes two sub-image groups, namely a visible light image group and a thermal imaging image group, and each of the visible light image group and the thermal imaging image group includes n images to be tested;
[0015] In step S4, all images to be tested in the same column of the image group to be tested are acquired in the same time period (preferably 1-2 seconds); and the time length for acquiring the image group to be tested in each column is the same. Wherein, n<10, preferably, n is 2, 4 or 5.
[0016] The counting model includes two neural network models, which are used to recognize visible light images and thermal imaging images respectively.
[0017] Wherein, the step S5 is specifically as follows:
[0018] Step S501: sequentially input the image to be tested corresponding to each column into the counting model, and the two sub-neural network models obtain the initial inspection result of each image to be tested, and the image to be tested with an animal face is counted as 1, and the image to be tested without an animal face is counted as 0; wherein,
[0019] Step S502: input all preliminary inspection results of the same image group to be tested into the correction model to obtain the final recognition result of the field;
[0020] Step S503: Count the final recognition results of all pens to obtain the number of animal targets.
[0021] The correction model in step S502 implements the correction method through the following formula (1):
[0022]
[0023] Where P j is the final recognition result of the jth column; the initial inspection result of the i-th image to be tested in the same visible light image group corresponding to the jth column is C i ; The initial inspection result of the i-th image to be tested in the same infrared image group corresponding to the j-th column is T i ; β is the confidence level, which is greater than 0.6 and less than the detection rate of the neural network image algorithm.
[0024] The step S503 is specifically implemented by the following formula (2):
[0025] P=∑P j j=1,2,3,...,m Formula (2).
[0026] Among them, the two sub-neural network models are both YOLOv4 neural networks.
[0027] Preferably, the visible light image sample library and the thermal imaging image sample library, as well as the visible light image group and the thermal imaging image group to be tested, are acquired using a visible light camera RealSense D435 and an infrared thermal imaging camera Arrow Optoelectronics AT600, respectively.
[0028] Preferably, when the step S4 acquires the image to be tested of each fence, an intelligent fence patrol vehicle can be used as a carrier; and the fence patrol method / mode is: moving horizontally from the first vertical column, taking an S-shaped route from the starting point to the end point, and controlling the stop time of the intelligent fence patrol vehicle in front of the fence according to the shooting time.
[0029] The beneficial effects of the present invention are as follows: the present invention is particularly suitable for the limited stall breeding environment in large-scale pig farms. The present invention can realize more accurate non-contact inventory of pigs in large-scale houses. Especially in the current situation where African swine fever is prevalent and strictly prevented and controlled, non-contact automatic measurement technology is particularly important, blocking the virus transmission route. At the same time, the present invention provides a new research direction for the automated monitoring and management of animals in pens. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a schematic diagram of the travel route of the intelligent patrol vehicle in Example 3 of the present invention.
[0031] Figure 2 Schematic diagram of pig head target detection in visible light images.
[0032] Figure 3 Schematic diagram of pig head target detection in thermal imaging images.
[0033] Figure 4 This is a schematic diagram of the process of Example 4. DETAILED DESCRIPTION
[0034] In order to clearly illustrate the technical features of this solution, this solution is described below through a specific implementation method.
[0035] Example 1
[0036] The embodiment of the present invention provides an animal target counting method based on a dual-light camera, which specifically includes the following steps:
[0037] Step S1: Acquire animal pen images to construct a sample library, with pen images with animal faces or heads as positive samples and pen images without animal faces as negative samples; wherein the acquired sample library includes two sub-sample libraries, namely a visible light image sample library and a thermal imaging image sample library.
[0038] Step S2: constructing a counting model, wherein the counting model includes two neural network models for animal identification, which are respectively used to identify visible light images and thermal imaging images, and the two neural network structure models can be preferably YOLOv4 neural networks; in addition, the counting model also includes a correction model connected to the back ends of the two neural network models, and the correction model is used to correct the recognition results of each pen and count the final recognition results of all pen to obtain the number of animal targets;
[0039] Step S3: input the sample library into the neural network model for training to obtain a trained neural network model;
[0040] Step S4: sequentially acquire the images to be tested of each column, each column corresponds to an image group to be tested, and each image group to be tested includes n images to be tested; the image group to be tested corresponding to each column acquired includes two sub-image groups, namely a visible light image group and a thermal imaging image group, and the visible light image group and the thermal imaging image group each include n images to be tested; in addition, all images to be tested (including visible light images and thermal imaging images) of the image group to be tested of the same column are acquired within the same time period; and the time length for acquiring the image group to be tested of each column is the same; in this embodiment, the image group to be tested of the same column is obtained by continuous shooting within 1 second.
[0041] Step S5: sequentially input the 2n images to be tested corresponding to each pen into the constructed counting model to obtain the final recognition result of each pen, and count the final recognition results of all pen to obtain the number of animal targets; wherein, step S5 is specifically as follows:
[0042] Step S501: sequentially input the image to be tested corresponding to each column into the counting model, and the two sub-neural network models obtain the initial inspection result of each image to be tested, and the image to be tested with an animal face is counted as 1, and the image to be tested without an animal face is counted as 0; wherein,
[0043] Step S502: input all preliminary inspection results of the same image group to be tested into the correction model to obtain the final recognition result of the field;
[0044] The correction model in step S502 implements the correction method through the following formula (1):
[0045]
[0046] Where P j is the final recognition result of the jth column; the initial inspection result of the i-th image to be tested in the same visible light image group corresponding to the jth column is C i ; The initial inspection result of the i-th image to be tested in the same infrared image group corresponding to the j-th column is T i ; β is the confidence level, which is greater than 0.6 and less than the detection rate of the neural network image algorithm;
[0047] Step S503: The final recognition results of all pens are counted using formula (2) to obtain the number of animal targets.
[0048] P=∑P j j=1,2,3,...,m Formula (2).
[0049] Example 2
[0050] On the basis of Example 1, the visible light image sample library and the thermal imaging image sample library, as well as the visible light image group and the thermal imaging image group to be tested, are acquired by using a visible light camera RealSense D435 and an infrared thermal imaging camera Arrow Optoelectronics AT600, respectively.
[0051] Example 3
[0052] On the basis of Example 1 or 2, when obtaining the image to be tested of each fence in step S4 of Example 1, a smart fence patrol vehicle (the smart fence patrol vehicle is a prior art and will not be described here) can be used as a carrier; and the fence patrol method / mode is: move horizontally from the first vertical column and take an S-shaped route from the starting point to the end point, and control the stop time of the smart fence patrol vehicle in front of the fence according to the shooting time.
[0053] See also Figure 1 , a specific plan is given; Figure 1In the system, the pens are divided into 4 vertical columns, and each vertical column has 100 measuring points (i.e. 100 pens) horizontally. The smart patrol vehicle moves horizontally from the 1st vertical column and takes an S-shaped route from the starting point to the end point. At least 2 visible light images and thermal imaging images of the pigs at each measuring point in each vertical column are taken (i.e. one visible light image and one infrared image). The pens are patrolled once a day. The smart patrol vehicle can control the shooting distance between the camera and the pigs to be consistent each time. The captured images are transmitted to the central control platform for real-time processing at the algorithm level, and the automatically generated data result report is stored and transmitted to the local computer for further analysis.
[0054] Example 4
[0055] On the basis of any one of Embodiments 1-3, this embodiment may also use a thermal imaging camera (Arrow Optoelectronics AT600) to simultaneously capture the temperature point data of the animal target. The target detection algorithm of this embodiment may be based on Embodiment 1 and may be based on a Windows / Ubuntu+Tensorflow+YOLO4 framework to achieve accurate positioning of the animal's head, and further quickly capture the temperature feature points of interest (e.g., the temperature of the eye sockets, ears, and the root of the nose) from the positioning frame. Figure 2 and Figure 3 As shown ( Figure 2 This is a schematic diagram of pig head target detection in visible light images, with the original image on the left and the processed and analyzed image on the right; Figure 3 (Figure 1) is a schematic diagram of target detection of pig heads in thermal imaging images, with the original image on the left and the processed and analyzed image on the right.) Among them, the smart fence patrol car can also be equipped with an integrated all-in-one sensor to simultaneously record the ambient temperature, humidity, wind speed, carbon dioxide, etc. of the fence measurement points, and summarize the daily and monthly animal daily reports together with the number of individual animals and temperature conditions; one of the uses of the animal daily report is to analyze the causes of pig deaths in the corresponding pens. In addition, the early temperature rise of pigs caused by disease can also be analyzed through the animal daily report, and professional management personnel can respond quickly. The entire operation process can be seen Figure 4 The process is mainly divided into parameter initialization, pen judgment, image acquisition, image processing, image display, data report generation, etc. The functions in the image processing process mainly include: image preprocessing (screening effective and clear-outline images, image denoising, enhancement, etc.), target detection (taking pigs as an example), extracting pig outline features, parameter output, etc. The data report includes parameters such as ambient temperature, humidity, wind speed, etc. of the measuring point, as well as temperature data measured during each, daily, weekly, and monthly inspections. By summarizing daily and monthly environmental and physiological parameters and other indicators, automatic measurement and automatic summary can be achieved, and they are associated with each individual, and historical data can be traced, truly realizing precision breeding.
[0056] Test Trial
[0057] A pig house with 1000 pigs, i.e. m=1000, was selected as the test target.
[0058] As a comparative example, a single camera and a single photo are used as the only image to be tested, and a single trained neural network model is used for recognition;
[0059] Taking the method of the present invention as an embodiment, specifically:
[0060] Based on the Windows / Ubuntu+Tensorflow+YOLO4 framework, a computing model was built and trained to maturity; among them, the recognition rate of the two trained neural network models (corresponding to visible light image recognition and thermal imaging image recognition respectively) reached 0.85 (that is, the probability of detecting the presence of a pig is 85% and the probability of misjudgment is 15%), and the confidence β of the subsequent modified model was set to 0.7 (that is, it meets the conditions of being greater than 0.6 and less than 0.85).
[0061] Among them, both the comparative example and the embodiment can utilize a smart patrol vehicle equipped with both a visible light camera (RealSense D435) and an infrared thermal imaging camera (Arrow Optoelectronics AT600) to realize front-end image acquisition; when the comparative example acquires the image to be tested, only the visible light camera or the infrared thermal imaging camera can be turned on.
[0062] After multiple tests, the target counting results were obtained (see Table 1).
[0063] Table 1 Comparison table of target counting results of each test method
[0064]
[0065]
[0066] It can be seen from Table 1 that the recognition rate of the comparative example using a single camera and a single photo as the only image to be tested is only about 85%. The reason is that it is not only an algorithm problem of the recognition model itself, but also because the pigs in the pens are in different shooting angles. When the pigs are in different states such as eating and drinking, the pigs' heads or faces may be hidden or tilted, so they cannot be counted, resulting in false detection. However, the recognition rate is higher than that of the comparative example when n is 2, 4 and 5 or more (n refers to the number of visible light images or thermal imaging images obtained within 1s, and the total number of images to be tested in the same pens is counted as 2n). In addition, considering the computing power of the computer's GPU, it is impossible to take an unlimited number of pictures to be tested. In combination with the computing power of the computer and the recognition rate, n is preferably 2, 4 or 5.
[0067] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for counting animal targets based on a dual-light camera, characterized in that: The method is: Step S1: Obtain animal stall images to construct a sample library, with stall images with animal faces as positive samples and stall images without animal faces as negative samples; Step S2: constructing a counting model, wherein the counting model includes a neural network model for animal identification; Step S3: input the sample library into the neural network model for training to obtain a trained neural network model; Step S4: sequentially acquiring the images to be tested of each column, each column corresponds to a group of images to be tested, and each group of images to be tested includes n images to be tested; Step S5: sequentially inputting the 2n images to be tested corresponding to each pen into the constructed counting model to obtain the final recognition result of each pen, and counting the final recognition results of all pen to obtain the number of animal targets; The image group to be tested corresponding to each column obtained in step S4 includes two sub-image groups, namely a visible light image group and a thermal imaging image group, and the visible light image group and the thermal imaging image group each include n images to be tested; the visible light image sample library and the thermal imaging image sample library, as well as the visible light image group and the thermal imaging image group to be tested, are obtained by using a visible light camera RealSense D435 and an infrared thermal imaging camera Arrow Optoelectronics AT600, respectively; In step S4, all images to be tested of the image group to be tested in the same column are acquired in the same time period, which is 1-2 seconds; and the time length for acquiring the image group to be tested in each column is the same; wherein n<10; When the image to be tested of each fence is obtained in step S4, the intelligent fence patrol vehicle is used as a carrier; and the fence patrol method is: moving horizontally from the first column, taking an S-shaped route from the starting point to the end point, and controlling the stop time of the intelligent fence patrol vehicle in front of the fence according to the shooting time; Wherein, the step S5 is specifically as follows: Step S501: sequentially input the image to be tested corresponding to each column into the counting model, and the two sub-neural network models obtain the initial inspection result of each image to be tested, and the image to be tested with an animal face is counted as 1, and the image to be tested without an animal face is counted as 0; wherein, Step S502: input all preliminary inspection results of the same image group to be tested into the correction model to obtain the final recognition result of the field; Step S503: Counting the final recognition results of all pens to obtain the number of animal targets; The correction model in step S502 implements the correction method through the following formula (1): Formula (1) In the formula, P j is the final recognition result of the jth column; j The columns correspond to the same visible light image group. i The initial inspection result of the image to be tested is C i ;No. j The first column in the same infrared image group i The initial inspection result of the image to be tested is T i ; β is the confidence level, β Greater than 0.6 and less than the detection rate of the neural network image algorithm; The counting model also includes a correction model connected to the back end of the neural network model, and the correction model is used to correct the recognition result of each pen and count the final recognition results of all the pen to obtain the number of animal targets; Both sub-neural network models are YOLOv4 neural networks; The target detection algorithm of the method is based on Windows / Ubuntu+Tensorflow+YOLO4 framework.
2. The method according to claim 1, characterized in that The sample library obtained in step S1 includes two sub-sample libraries, namely a visible light image sample library and a thermal imaging image sample library.
3. The method according to claim 1, characterized in that The counting model includes two neural network models, which are used to recognize visible light images and thermal imaging images respectively.
4. The method according to claim 1, characterized in that: The step S503 is specifically implemented by the following formula (2): Formula (2).
