Breeding duck status image recognition method and system based on video monitoring
By performing grayscale processing and binary processing on the breeding duck image, the difference in fluctuation between the two feet is calculated to judge the lame, the problems of inaccurate and low efficiency of manual identification in the prior art are solved, and more efficient and accurate lame recognition is achieved.
Patent Information
- Application Number
- CN202411887202.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-20
AI Technical Summary
The existing breeding duck lame recognition methods rely on manual recognition, resulting in inaccurate identification and inefficient efficiency.
By acquiring the image of the breeding duck with multiple consecutive frames, performing grayscale image processing and binarization processing, obtaining the breeding duck profile, and comparing the fluctuation difference between the two legs with the normal fluctuation threshold to determine whether the breeding duck is lame.
It reduces labor costs, improves identification accuracy and efficiency, and can more accurately identify lame ducks.
Smart Images

Figure CN119339412B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of breeding duck image recognition, and in particular to a breeding duck state image recognition method and system based on video monitoring. Background Art
[0002] Lameness of breeder ducks will seriously affect their growth and reproductive performance, leading to a decrease in egg production, increasing the risk of disease transmission, increasing breeding costs, and reducing economic benefits. By identifying lame breeder ducks and screening and removing them, farmers can conduct early intervention and precise management. Therefore, identifying lameness of breeder ducks is a very important step.
[0003] With the advancement of science and technology, smart farming technology has gradually become a new trend in the farming industry. The identification of lameness in breeding ducks is combined with image recognition. By analyzing the movement of the duck flock, it can accurately identify the symptoms of lameness and help farmers to carry out early intervention and precise management. The application of this technology not only improves the recognition efficiency, but also promotes the development of smart agriculture. The existing method for identifying lameness in breeding ducks is manual recognition. Manual identification of lameness requires constant observation of the walking conditions of the breeding ducks, which consumes a lot of manual time. In addition, manual identification has subjective judgments, resulting in inaccurate identification of lameness and low recognition efficiency. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems in the prior art to a certain extent, by acquiring multiple frames of continuous breeding duck images, performing grayscale image processing on the breeding duck images to obtain a breeding duck grayscale image, performing binarization processing on the breeding duck grayscale image to obtain a breeding duck binary image, obtaining the breeding duck outline based on the breeding duck binary image, obtaining the fluctuation difference between the two feet of the breeding duck, obtaining a normal fluctuation threshold, and judging whether the breeding duck is lame based on the fluctuation difference between the two feet of the breeding duck and the normal fluctuation threshold, so as to solve the problem that the existing breeding duck lameness identification technology uses manual identification of breeding ducks, resulting in inaccurate identification of breeding duck lameness and low identification efficiency.
[0005] To achieve the above objectives, in a first aspect, the present application provides a method for identifying duck status images based on video surveillance, comprising the following steps:
[0006] Acquire multiple frames of continuous breeding duck images based on surveillance cameras;
[0007] The breeding duck image is subjected to grayscale image processing to obtain a breeding duck grayscale image, the breeding duck grayscale image is subjected to binarization processing to obtain a breeding duck binary image, and the breeding duck outline is obtained based on the breeding duck binary image;
[0008] Obtain the difference in fluctuations between the two feet of the breeder duck based on the breeder duck outlines of multiple consecutive frames;
[0009] The normal fluctuation threshold is obtained based on the fluctuation difference between the two feet of a normal breeder duck when walking;
[0010] Whether the breeder duck is lame is determined based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold.
[0011] Furthermore, obtaining multiple frames of continuous breeding duck images based on a surveillance camera includes the following sub-steps:
[0012] A corridor with freely adjustable width is set up, the corridor is set with a starting point and an end point, and a surveillance camera is set above the end point of the corridor;
[0013] Obtain the real-time growth month of the breeding duck and the body width function of the breeding duck, substitute the real-time growth month of the breeding duck into the body width function of the breeding duck to obtain the body width of the breeding duck, and set the body width of the breeding duck as Tks;
[0014] Set the width of the corridor to: Tks+k1; k1 is the safe passage constant;
[0015] The gait cycle of the breeder duck is obtained, and the gait cycle is set as Bt; and multiple frames of continuous breeder duck images are obtained within the gait cycle time.
[0016] Furthermore, obtaining the body width function of the breeding duck includes the following sub-steps:
[0017] Obtain a first number of breeding ducks in different months, count the months of the breeding ducks and the body widths of the breeding ducks, mark the months of the breeding ducks as Nl, and mark the body widths of the breeding ducks as Tk;
[0018] With the month of the breeder duck as the X-axis and the body width of the breeder duck as the Y-axis, a plane rectangular coordinate system is established, marked as the body width coordinate system;
[0019] Plot the month of each group of breeder ducks and the body width of the corresponding breeder ducks into the body width coordinate system to obtain a body width scatter plot;
[0020] Set the default duck body width function to:
[0021] , where a, b and c are constants;
[0022] The body width scatter plot was fitted with the preset breeder duck body width function to obtain the breeder duck body width function.
[0023] Furthermore, obtaining the gait cycle of the breeding duck includes the following sub-steps:
[0024] Get the second number of real-time month breeders, mark the second number as P, get the number of steps of all real-time month breeders in the first time, mark it as O i ; Mark the first time as T1;
[0025] Calculate the gait cycle of the breeder duck as: ;
[0026] Furthermore, performing grayscale image processing on the breeding duck image to obtain a breeding duck grayscale image includes the following sub-steps:
[0027] Get the RGB value of each pixel in the breeding duck image;
[0028] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0029] H=0.299*R+0.587* G+0.114*B; H is the gray value, and R, G and B are three values in RGB value.
[0030] Furthermore, the grayscale image of the breeding duck is binarized to obtain a binary image of the breeding duck, and obtaining the outline of the breeding duck based on the binary image of the breeding duck includes the following sub-steps:
[0031] Divide the grayscale value of 0-255 into e equal intervals;
[0032] Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency;
[0033] Draw a histogram with gray value as X-axis and interval frequency as Y-axis, marked as gray histogram; by drawing the histogram, it is easy to observe the gray value of the background of the corridor and the duck, which is convenient for subsequent binarization processing;
[0034] Add up all interval frequencies to get the total frequency, marked as U;
[0035] If there is an interval whose frequency is less than U / e, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If so, the low-frequency area is marked as the initial threshold area.
[0036] Determine whether there are multiple initial threshold regions. If there is only one initial threshold region, mark the initial threshold region as the final threshold region; if there are multiple initial threshold regions, obtain the maximum value point on the X-axis of any initial threshold region, mark it as a larger split point, and calculate the sum of the interval frequencies greater than the larger split point, marked as Psd; obtain the minimum value point on the X-axis of any initial threshold region, mark it as a smaller split point, calculate the sum of the interval frequencies less than the smaller split point, marked as Psx, calculate the absolute value of the difference between Psd and Psx and set it as the frequency difference; frequency difference = |Psd-Psx|; calculate the frequency difference of each initial threshold region, and mark the initial threshold region corresponding to the minimum value among the multiple frequency differences as the final threshold region;
[0037] The midpoint value of the abscissa of the final threshold area is set as the separation threshold; the grayscale value of the pixel points greater than or equal to the separation threshold is set to 255, and the grayscale value of the pixel points less than the separation threshold is set to 0;
[0038] If a pixel with a grayscale value of 255 is adjacent to a pixel with a grayscale value of 0, the pixel with a grayscale value of 255 is marked as a breeding duck edge pixel;
[0039] Count all the edge pixels of the breeding ducks and mark them as the breeding duck outlines.
[0040] Furthermore, obtaining the fluctuation difference of the two feet of the breeding duck based on the continuous multiple frames of the breeding duck outline image includes the following sub-steps:
[0041] Establish a plane rectangular coordinate system and place the outline of the breeding duck in the first quadrant;
[0042] Set the coordinate point of the duck outline in the rectangular coordinate system to (x i ,y i ), get an x respectively i The maximum value of x i The minimum value of y i The maximum value of y i The coordinates of the minimum value of max , y1), (x min , y2), (x1, y max ) and (x2, y min ), then get (x max , y1) and parallel to the Y axis, through (x min , y2) and parallel to the Y axis, through (x1, y max ) and parallel to the X-axis and the line segment passing through (x2, y min ) and parallel to the X-axis. The four line segments form a rectangle. Get the lower left corner point of the rectangle (x zx ,y zx ) and the upper right corner (x ys ,y ys ), get point , marked as the center point of the breeding duck;
[0043] Obtain the center points of all the ducklings of the same duckling, and make the center points of all the ducklings overlap;
[0044] Draw a dividing line through the center point of the breeder duck and parallel to the Y axis, and use the dividing line to divide the breeder duck outline into two parts, left and right, marked as the left outline and the right outline;
[0045] Get the smallest pixel points of the Y-axis coordinates of all left and right contours respectively, and mark them as the left foot detection pixel point and the right foot detection pixel point respectively;
[0046] Get the minimum value Zx and the maximum value Zd of all detected left foot pixels on the Y axis;
[0047] Get the minimum value Yx and the maximum value Yd of all detected right foot pixels on the Y axis;
[0048] The difference between Zd and Zx is calculated as: Zs=Zd-Zx; where Zs is the difference between Zd and Zx;
[0049] The difference between Yd and Yx is calculated as: Ys=Yd-Yx; where Ys is the difference between Yd and Yx;
[0050] The absolute value of the difference between Zs and Ys is calculated as: Cz=|Zs-Ys|; where Cz is the absolute value of the difference between Zs and Ys.
[0051] Furthermore, obtaining a normal fluctuation threshold based on the fluctuation difference between the two feet of a normal breeder duck when walking includes the following sub-steps:
[0052] Obtain a third number of normal breeding ducks, obtain the smallest pixel points of the Y-axis coordinates of the left contours and the right contours of all normal breeding ducks, and mark them as normal left foot pixel points and normal right foot pixel points respectively;
[0053] Get the minimum value Zxs and the maximum value Zds of the Y-axis of the normal left foot pixel of each breeder duck;
[0054] Get the minimum value of the normal right foot pixel of each breeder duck on the Y axis as Yxs and the maximum value as Yds;
[0055] The difference between Zds and Zxs is calculated as: Zss=Zds-Zxs; where Zss is the difference between Zds and Zxs;
[0056] The difference between Yds and Yxs is calculated as: Yss=Yds-Yxs; where Yss is the difference between Yds and Yxs;
[0057] Calculate the absolute value of all Zss and Yss differences: Czs=|Zss-Yss|; where Czs is the absolute value of the difference between Zss and Yss;
[0058] Divide Czs evenly into multiple intervals, count the frequency of breeder ducks in each interval, and mark the frequency of breeder ducks in the interval;
[0059] With Czs as the X-axis and the frequency of interval breeder ducks as the Y-axis, draw a difference histogram;
[0060] Observe the difference histogram. If the interval breeding duck frequency is less than the distribution threshold, delete the interval breeding duck frequency, obtain the maximum value of Czs in the difference histogram, and mark the maximum value of Czs as the normal fluctuation threshold.
[0061] Furthermore, judging whether the breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold comprises the following sub-steps:
[0062] Determine the size of Cz and Czs. If Cz is greater than or equal to Czs, the duck is judged to be lame. If Cz is less than Czs, the duck is judged not to be lame.
[0063] In a second aspect, the present application also provides a breeding duck status image recognition system based on video monitoring, including an image acquisition module, an image processing module, a data acquisition module, a threshold acquisition module and a lameness judgment module;
[0064] The image acquisition module is used to acquire multiple frames of continuous breeding duck images based on a monitoring camera;
[0065] The image processing module is used to perform grayscale image processing on the breeding duck image to obtain a breeding duck grayscale image, perform binarization processing on the breeding duck grayscale image to obtain a breeding duck binary image, and obtain the breeding duck outline based on the breeding duck binary image;
[0066] The data acquisition module is used to acquire the fluctuation difference between the two feet of the breeding duck based on the outline of the breeding duck in multiple consecutive frames;
[0067] The threshold value acquisition module is used to acquire a normal fluctuation threshold value based on the fluctuation difference between the two feet of a normal breeder duck when walking;
[0068] The lameness judgment module is used to judge whether the breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold.
[0069] Beneficial effects of the present invention: the present invention obtains multiple frames of continuous breeding duck images, performs grayscale image processing on the breeding duck images to obtain a breeding duck grayscale image, performs binarization processing on the breeding duck grayscale image to obtain a breeding duck binarization image, obtains the breeding duck outline based on the breeding duck binarization image, obtains the fluctuation difference between the two feet of the breeding duck, obtains the normal fluctuation threshold, and judges whether the breeding duck is lame based on the fluctuation difference between the two feet of the breeding duck and the normal fluctuation threshold. The advantage is that the fluctuation difference between the two feet of the breeding duck obtained by using the breeding duck images is compared with the normal fluctuation threshold to judge whether the breeding duck is lame, which reduces labor costs, increases recognition accuracy, and improves recognition efficiency;
[0070] The present invention obtains the body width function of breeding ducks. The advantage is that the relationship between the historical breeding duck months and the body width of breeding ducks is used, and then the body width function of breeding ducks is obtained through function fitting, so that the set corridor width can only pass through one breeding duck, which is convenient for obtaining the fluctuation difference between the two feet of a breeding duck and improving the accuracy of recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 is a flow chart of the steps of the method of the present invention;
[0072] Figure 2 This is a schematic diagram of the body width function of the breeding duck of the present invention;
[0073] Figure 3 Schematic diagram of the grayscale histogram of the present invention;
[0074] Figure 4 Schematic diagram of obtaining the center point of the breeding duck of the present invention;
[0075] Figure 5 Schematic diagram of obtaining the detected left - foot pixel points and detected right - foot pixel points of the present invention;
[0076] Figure 6 Schematic diagram of the difference histogram of the present invention;
[0077] Figure 7 Principle block diagram of the system of the present invention. Detailed implementation manners
[0078] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0079] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides a breeding duck status image recognition system based on video monitoring, including: an image acquisition module, an image processing module, a data acquisition module, a threshold acquisition module, and a lameness judgment module;
[0080] The image acquisition module is used to acquire continuous multiple frames of breeding duck images based on a monitoring camera;
[0081] The image acquisition module is configured with a strategy for acquiring breeding duck images, and the strategy for acquiring breeding duck images includes:
[0082] Set a long corridor with a freely adjustable width, the long corridor is provided with a starting point and an ending point, and a monitoring camera is set above the ending point of the long corridor; wherein the long corridor is set with a color to distinguish it from the color of the breeding duck. For example, if the color of the breeding duck is mainly white, then the background color of the long corridor is set to black to facilitate subsequent distinguishing of the breeding duck contour;
[0083] Obtain the real - time breeding duck growth month and the breeding duck body width function, substitute the real - time breeding duck growth month into the breeding duck body width function to obtain the breeding duck body width, and set the breeding duck body width as Tks;
[0084] Set the width of the long corridor as: Tks + k1; where k1 is a safety passage constant; the setting of k1 is such that only one breeding duck can pass through, and at the same time, it is necessary to ensure the smooth passage of the breeding duck, where 0 < k1 < Tks; preferably, k1 = 0.5 * Tks;
[0085] Obtain the gait cycle of the breeding duck and set the gait cycle as Bt; the gait cycle is the time it takes for the breeding duck's left foot and right foot to take one step each; obtain the gait cycle to facilitate the use of the gait cycle to limit the time range of capturing images of the surveillance video;
[0086] Acquire multiple continuous frames of images of breeding ducks during the gait cycle time.
[0087] The image acquisition module is configured with a strategy for obtaining a function of the body width of a breeding duck, and the strategy for obtaining a function of the body width of a breeding duck includes: obtaining a first number of breeding ducks in different months, counting the months of the breeding ducks and the body widths of the breeding ducks, marking the months of the breeding ducks as Nl, and marking the body widths of the breeding ducks as Tk;
[0088] With the month of the breeder duck as the X-axis and the body width of the breeder duck as the Y-axis, a plane rectangular coordinate system is established, marked as the body width coordinate system;
[0089] Plot the month of each group of breeder ducks and the body width of the corresponding breeder ducks into the body width coordinate system to obtain a body width scatter plot;
[0090] Set the default duck body width function to:
[0091] , where a, b and c are constants; using the gompertz curve formula to fit, the Gompertz curve is characterized by slow growth in the early and late stages, and rapid growth in the middle stage, which is consistent with the growth of the width of the breeding duck with the month;
[0092] The body width scatter plot was fitted with the preset breeder duck body width function to obtain the breeder duck body width function.
[0093] For practical applications, please refer to Figure 2 As shown in the figure, if the fitting results are a=50, b=2 and c=0.3, the preset duck body width function is:
[0094] ;
[0095] The image acquisition module is configured with a strategy for acquiring the gait cycle of the breeder ducks. The strategy for acquiring the gait cycle of the breeder ducks includes: acquiring the second number of breeder ducks in the real-time month, marking the second number as P, acquiring the number of steps of all the breeder ducks in the real-time month in the first time, marking it as O. i ; Mark the first time as T1;
[0096] Calculate the gait cycle of the breeder duck as: . Calculate the average gait cycle time of a duck through a large number of different step count data;
[0097] In practical application, take two ducks as an example, set the first time to 100 seconds, one duck takes 202 steps, and the other takes 198 steps. Therefore, the gait cycle of the duck is calculated as: 2*(100 / 202+100 / 198) / 2=1.00 seconds, and the result is rounded to two decimal places.
[0098] The image processing module is used to perform grayscale image processing on the breeding duck image to obtain a breeding duck grayscale image, perform binarization processing on the breeding duck grayscale image to obtain a breeding duck binary image, and obtain the breeding duck outline based on the breeding duck binary image;
[0099] The image processing module is configured with a strategy for obtaining a grayscale image of a breeder duck, and the strategy for obtaining a grayscale image of a breeder duck includes: obtaining the RGB value of each pixel in the breeder duck image;
[0100] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0101] H=0.299*R+0.587* G+0.114*B; H is the grayscale value, R, G and B are three values in RGB value; the weight here is based on the human eye's perception of brightness, among which green contributes the most to brightness, red second, and blue the least;
[0102] The image processing module is configured with a strategy for obtaining the outline of the breeding duck, and the strategy for obtaining the outline of the breeding duck includes: dividing the grayscale value of 0-255 into e equal intervals;
[0103] Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency;
[0104] Draw a histogram with grayscale value as X-axis and interval frequency as Y-axis, marked as grayscale histogram;
[0105] Add up all interval frequencies to get the total frequency, marked as U;
[0106] If there is an interval with an interval frequency less than U / e, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If there are, the low-frequency area is marked as the initial threshold area; U / e is the average value of the interval frequency. If it is less than the average value, the distribution is small.
[0107] See also Figure 3As shown, it is determined whether there are multiple initial threshold regions. If there is only one initial threshold region, the initial threshold region is marked as the final threshold region; if there are multiple initial threshold regions, the maximum value point on the X-axis of any initial threshold region is obtained, marked as a larger split point, and the sum of the interval frequencies greater than the larger split point is obtained, marked as Psd, and the minimum value point on the X-axis of any initial threshold region is obtained, marked as a smaller split point, and the sum of the interval frequencies less than the smaller split point is obtained, marked as Psx, and the absolute value of the difference between Psd and Psx is obtained and set as the frequency frequency difference; frequency difference = |Psd-Psx|; obtain the frequency difference of each initial threshold area, and mark the initial threshold area corresponding to the minimum value of multiple frequency differences as the final threshold area; in the process of image acquisition, the stains caused by the walking of the breeder ducks may cause multiple initial threshold areas to appear in the color background, so the initial threshold area judgment and the setting of the initial threshold are proposed. Because the gallery background and the breeder duck image are the main ones in the breeder duck image, and the proportion of the image is not much different, the initial threshold area is approximately in the middle area, that is, the final threshold area is when the frequency difference is the smallest;
[0108] The midpoint value of the abscissa of the final threshold area is set as the separation threshold; the grayscale value of the pixel points greater than or equal to the separation threshold is set to 255, and the grayscale value of the pixel points less than the separation threshold is set to 0;
[0109] If a pixel with a grayscale value of 255 is adjacent to a pixel with a grayscale value of 0, the pixel with a grayscale value of 255 is marked as a breeding duck edge pixel;
[0110] Count all the edge pixels of the breeding ducks and mark them as the breeding duck outlines.
[0111] The data acquisition module is used to obtain the fluctuation difference between the two feet of the breeding duck based on the outline of the breeding duck in multiple consecutive frames;
[0112] The data acquisition module is configured with a Cz acquisition strategy, which includes: establishing a plane rectangular coordinate system and placing the breeder duck outline in the first quadrant;
[0113] Set the coordinate point of the duck outline in the rectangular coordinate system to (x i ,y i ), get an x respectively i The maximum value of x i The minimum value of y i The maximum value of y i The coordinates of the minimum value of max , y1), (x min , y2), (x1, y max ) and (x2, y min ), then get (x max , y1) and parallel to the Y axis, through (xmin , y2) and parallel to the Y axis, through (x1, y max ) and parallel to the X-axis and the line segment passing through (x2, y min ) and parallel to the X-axis. The four line segments form a rectangle. Get the lower left corner point of the rectangle (x zx ,y zx ) and the upper right corner (x ys ,y ys ), get point , marked as the center point of the breeding duck;
[0114] For practical applications, please refer to Figure 4 As shown, get an x respectively i The maximum value of x i The minimum value of y i The maximum value of y i The coordinates of the minimum value are marked as (12, 5), (6, 4), (6, 16) and (5, 2), and then the line segment passing through (12, 5) and parallel to the Y axis, the line segment passing through (6, 4) and parallel to the Y axis, the line segment passing through (6, 16) and parallel to the X axis, and the line segment passing through (5, 2) and parallel to the X axis are obtained. The four line segments form a rectangle. The lower left corner point (5, 4) and the upper right corner point (12, 16) of the rectangle are obtained, and the point (8.5, 10) is obtained and marked as the center point of the breeding duck;
[0115] See also Figure 5 As shown, the center points of all the duckling contours of the same duckling are obtained, and the center points of all the duckling contours are overlapped;
[0116] Draw a dividing line through the center point of the breeder duck and parallel to the Y axis, and use the dividing line to divide the breeder duck outline into two parts, left and right, marked as the left outline and the right outline;
[0117] The smallest pixel points of the Y-axis coordinates of all left and right contours are obtained respectively, and are marked as the left foot detection pixel point and the right foot detection pixel point respectively; when the breeder duck is lame, the height of the two feet of the breeder duck is different, so whether the breeder duck is lame can be judged according to the height difference between the left foot pixel point and the right foot pixel point;
[0118] Get the minimum value Zx and the maximum value Zd of all detected left foot pixels on the Y axis;
[0119] Get the minimum value Yx and the maximum value Yd of all detected right foot pixels on the Y axis;
[0120] The difference between Zd and Zx is calculated as: Zs=Zd-Zx; where Zs is the difference between Zd and Zx;
[0121] The difference between Yd and Yx is calculated as: Ys=Yd-Yx; where Ys is the difference between Yd and Yx;
[0122] The absolute value of the difference between Zs and Ys is calculated as: Cz=|Zs-Ys|; where Cz is the absolute value of the difference between Zs and Ys;
[0123] In practical applications, the minimum value of all detected left foot pixel points on the Y axis is Zx=3.1, and the maximum value is Zd=9.2; the minimum value of all detected right foot pixel points on the Y axis is Yx=3.3, and the maximum value is Yd=8.9; the difference between Zd and Zx is calculated as: Zs=Zd-Zx=6.1; where Zs is the difference between Zd and Zx; the difference between Yd and Yx is calculated as: Ys=Yd-Yx=5.6; where Ys is the difference between Yd and Yx; the absolute value of the difference between Zs and Ys is calculated as: Cz=|Zs-Ys|=0.5.
[0124] The threshold value acquisition module is used to obtain the normal fluctuation threshold value based on the fluctuation difference between the two feet of the normal breeder duck when walking;
[0125] The threshold acquisition module is configured with a normal fluctuation threshold acquisition strategy, which includes: acquiring a third number of normal breed ducks, respectively acquiring the smallest pixel points of the Y-axis coordinates of the left contours and the right contours of all normal breed ducks, and marking them as normal left foot pixel points and normal right foot pixel points respectively;
[0126] Get the minimum value Zxs and the maximum value Zds of the Y-axis of the normal left foot pixel of each breeder duck;
[0127] Get the minimum value of the normal right foot pixel of each breeder duck on the Y axis as Yxs and the maximum value as Yds;
[0128] The difference between Zds and Zxs is calculated as: Zss=Zds-Zxs; where Zss is the difference between Zds and Zxs;
[0129] The difference between Yds and Yxs is calculated as: Yss=Yds-Yxs; where Yss is the difference between Yds and Yxs;
[0130] Calculate the absolute value of all Zss and Yss differences: Czs=|Zss-Yss|; where Czs is the absolute value of the difference between Zss and Yss;
[0131] Divide Czs evenly into multiple intervals, count the frequency of breeder ducks in each interval, and mark the frequency of breeder ducks in the interval;
[0132] With Czs as the X-axis and the frequency of interval breeder ducks as the Y-axis, draw a difference histogram;
[0133] Observe the difference histogram. If the interval breeding duck frequency is less than the distribution threshold, delete the interval breeding duck frequency, obtain the maximum value of Czs in the difference histogram, and mark the maximum value of Czs as the normal fluctuation threshold. The specific setting of the distribution threshold can be obtained according to the distribution of the histogram. For example, the interval breeding duck frequency of the larger Czs in the difference histogram is smaller. The minimum Czs in the interval breeding duck frequency of the larger Czs in the difference histogram is obtained and set as the distribution threshold;
[0134] The lameness judgment module is used to judge whether the breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold.
[0135] For practical applications, please refer to Figure 6 As shown, observing the difference histogram, the distribution threshold is set to 1.5cm, that is, the maximum value of Czs in the difference histogram is 1.5cm, and Czs=1.5 is marked as the normal fluctuation threshold;
[0136] The lameness judgment module is configured with a lameness judgment strategy, and the lameness judgment strategy includes: judging the size of Cz and Czs, if Cz is greater than or equal to Czs, the duck is judged to be lame, if Cz is less than Czs, the duck is judged not to be lame; the principle is that the lame duck has two feet with different heights, that is, the duck with too large a fluctuation is a lame duck;
[0137] In practical applications, the size of Cz and Czs is judged. If Cz=0.5 and Czs=1.5, that is, Cz is less than Czs, it is determined that the duck is not lame.
[0138] Example 2, please refer to Figure 7 As shown, in the second aspect, the present application provides a method for identifying the state image of a breeding duck based on video surveillance, comprising the following steps: Step S1, obtaining multiple frames of continuous breeding duck images based on a surveillance camera; Step S1 comprises the following sub-steps:
[0139] Step S101, setting a corridor with a freely adjustable width, the corridor is provided with a starting point and an end point, and a surveillance camera is set above the end point of the corridor;
[0140] Step S102, obtaining the real-time growth month of the breeding duck and the breeding duck body width function, substituting the real-time growth month of the breeding duck into the breeding duck body width function to obtain the breeding duck body width, and setting the breeding duck body width as Tks; Step S102 includes the following sub-steps:
[0141] Step S10201, obtaining a first number of breeding ducks in different months, counting the months of the breeding ducks and the body widths of the breeding ducks, marking the months of the breeding ducks as N1, and marking the body widths of the breeding ducks as Tk;
[0142] Step S10202, using the month of the breeder duck as the X-axis and the body width of the breeder duck as the Y-axis, a plane rectangular coordinate system is established, which is marked as a body width coordinate system;
[0143] Step S10203, plotting the month of each group of breeding ducks and the body width of the corresponding breeding ducks into a body width coordinate system to obtain a body width scatter plot;
[0144] Step S10204, setting the preset breeding duck body width function to:
[0145] , where a, b and c are constants;
[0146] Step S10205, fitting the body width scatter plot with a preset breeding duck body width function to obtain a breeding duck body width function.
[0147] Step S103, setting the width of the corridor to: Tks+k1; where k1 is a safe passage constant;
[0148] Step S104, obtaining the gait cycle of the breeding duck, and setting the gait cycle as Bt; Step S104 includes the following sub-steps:
[0149] Step S10401, obtain the second number of real-time month breeding ducks, mark the second number as P, obtain the number of steps of all real-time month breeding ducks in the first time, mark it as O i ; Mark the first time as T1;
[0150] Step S10402, calculating the gait cycle of the breeder duck: ;
[0151] Step S15, acquiring multiple frames of continuous breeding duck images within the gait cycle time.
[0152] Step S2, performing grayscale image processing on the breeding duck image to obtain a breeding duck grayscale image, performing binarization processing on the breeding duck grayscale image to obtain a breeding duck binary image, and obtaining the breeding duck outline based on the breeding duck binary image; Step S2 includes the following sub-steps:
[0153] Step S201, obtaining the RGB value of each pixel in the breeding duck image;
[0154] Step S202, converting the RGB value into a gray value using a gray conversion formula, the gray conversion formula is: H=0.299*R+0.587*G+0.114*B; wherein H is the gray value, and R, G and B are three values in the RGB value;
[0155] Step S203, divide the grayscale values of 0-255 into e equal intervals; count the frequency of the grayscale values in each equal interval respectively, and mark it as interval frequency;
[0156] Step S204, draw a histogram with the gray value as the X-axis and the interval frequency as the Y-axis, marked as a gray histogram;
[0157] Step S205, add up all the interval frequencies to get the total frequency, marked as U; if there is an interval with an interval frequency less than U / e, mark it as a low-frequency area, and mark the interval other than the low-frequency area as a high-frequency area, and determine whether there are high-frequency areas on both sides of the low-frequency area. If so, mark the low-frequency area as the initial threshold area;
[0158] Step S206, determine whether there are multiple initial threshold regions. If there is only one initial threshold region, mark the initial threshold region as the final threshold region; if there are multiple initial threshold regions, obtain the maximum value point on the X-axis of any initial threshold region, mark it as a larger segmentation point, calculate the sum of the interval frequencies greater than the larger segmentation point, mark it as Psd, obtain the minimum value point on the X-axis of any initial threshold region, mark it as a smaller segmentation point, calculate the sum of the interval frequencies less than the smaller segmentation point, mark it as Psx, calculate the absolute value of the difference between Psd and Psx and set it as the frequency difference; frequency difference = |Psd-Psx|; calculate the frequency difference of each initial threshold region, and mark the initial threshold region corresponding to the minimum value among the multiple frequency differences as the final threshold region;
[0159] Step S207, setting the midpoint value of the abscissa of the final threshold area as the separation threshold; setting the grayscale value of the pixel points greater than or equal to the separation threshold to 255, and setting the grayscale value of the pixel points less than the separation threshold to 0;
[0160] Step S208, if a pixel with a grayscale value of 255 is adjacent to a pixel with a grayscale value of 0, mark the pixel with a grayscale value of 255 as a breeding duck edge pixel; count all breeding duck edge pixels and mark them as breeding duck outlines.
[0161] Step S3, obtaining the fluctuation difference between the two feet of the breeding duck based on the breeding duck outline of multiple consecutive frames; Step S3 includes the following sub-steps:
[0162] Step S301, establishing a plane rectangular coordinate system, placing the outline of the breeding duck in the first quadrant;
[0163] Step S302, setting the coordinate point of the breeding duck outline in the rectangular coordinate system as (x i ,y i ), get an x respectively i The maximum value of x i The minimum value of y i The maximum value of y i The coordinates of the minimum value of max , y1), (x min , y2), (x1, y max ) and (x2, y min ), then get (x max, y1) and parallel to the Y axis, through (x min , y2) and parallel to the Y axis, through (x1, y max ) and parallel to the X-axis and the line segment passing through (x2, y min ) and parallel to the X-axis. The four line segments form a rectangle. Get the lower left corner point of the rectangle (x zx ,y zx ) and the upper right corner (x ys ,y ys ), get point , marked as the center point of the breeding duck;
[0164] Step S303, obtaining the center points of all the breeder ducks' outlines of the same breeder duck, and overlapping the center points of all the breeder ducks' outlines;
[0165] Step S304, draw a dividing line through the center point of the breeder duck and parallel to the Y axis, and use the dividing line to divide the breeder duck outline into two parts, left and right, marked as a left outline and a right outline;
[0166] Step S305, respectively obtaining the smallest pixel points of the Y-axis coordinates of all left contours and right contours, and marking them as the detected left foot pixel points and the detected right foot pixel points respectively;
[0167] Step S306, obtaining the minimum value Zx and the maximum value Zd of all detected left foot pixel points on the Y axis;
[0168] Step S307, obtaining the minimum value Yx and the maximum value Yd of all detected right foot pixel points on the Y axis;
[0169] Step S308, calculate the difference between Zd and Zx as: Zs=Zd-Zx; wherein Zs is the difference between Zd and Zx; calculate the difference between Yd and Yx as: Ys=Yd-Yx; wherein Ys is the difference between Yd and Yx;
[0170] The absolute value of the difference between Zs and Ys is calculated as: Cz=|Zs-Ys|; where Cz is the absolute value of the difference between Zs and Ys.
[0171] Step S4, obtaining a normal fluctuation threshold value based on the fluctuation difference between the two feet of a normal breeder duck when walking; Step S4 includes the following sub-steps:
[0172] Step S401, obtaining a third number of normal breeding ducks, respectively obtaining the smallest pixel points of the Y-axis coordinates of the left contours and the right contours of all normal breeding ducks, and marking them as normal left foot pixel points and normal right foot pixel points respectively;
[0173] Step S402, obtaining the minimum value Zxs and the maximum value Zds of the normal left foot pixel point on the Y axis of each breeding duck;
[0174] Step S403, obtaining the minimum value Yxs and the maximum value Yds of the normal right foot pixel point of each breeding duck on the Y axis;
[0175] Step S404, calculate the difference between Zds and Zxs as: Zss=Zds-Zxs; wherein Zss is the difference between Zds and Zxs; calculate the difference between Yds and Yxs as: Yss=Yds-Yxs; wherein Yss is the difference between Yds and Yxs; calculate the absolute value of all Zss and Yss differences as: Czs=|Zss-Yss|; wherein Czs is the absolute value of the difference between Zss and Yss;
[0176] Step S405, evenly divide Czs into multiple intervals, count the frequency of breeding ducks in each interval, and mark the frequency of breeding ducks in the interval;
[0177] Step S406, plotting a difference histogram with Czs as the X-axis and the frequency of the interval breeder ducks as the Y-axis;
[0178] Step S407, observe the difference histogram, if the interval breeder duck frequency is less than the distribution threshold, delete the interval breeder duck frequency, obtain the maximum value of Czs in the difference histogram, and mark the maximum value of Czs as the normal fluctuation threshold.
[0179] Step S5, judging whether the breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold; Step S5 includes the following sub-steps:
[0180] Step S501, determine the size of Cz and Czs. If Cz is greater than or equal to Czs, determine that the duck is lame. If Cz is less than Czs, determine that the duck is not lame.
[0181] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0182] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
Claims
1. A method for identifying the state of breeding ducks based on video monitoring, characterized in that: The steps include: Acquire multiple frames of continuous breeding duck images based on surveillance cameras; The breeding duck image is subjected to grayscale image processing to obtain a breeding duck grayscale image, the breeding duck grayscale image is subjected to binarization processing to obtain a breeding duck binary image, and the breeding duck outline is obtained based on the breeding duck binary image; Obtain the difference of the fluctuation of the two feet of the breeder duck based on the outline of the breeder duck in multiple consecutive frames; Obtaining the fluctuation difference of the two feet of the breeding duck based on the continuous multi-frame breeding duck outline image includes the following sub-steps: Establish a plane rectangular coordinate system and place the outline of the breeding duck in the first quadrant; Set the coordinate point of the duck outline in the rectangular coordinate system to (x i ,y i ), get an x respectively i The maximum value of x i The minimum value of y i The maximum value of y i The coordinates of the minimum value of max , y1), (x min , y2), (x1, y max ) and (x2, y min ), then get (x max , y1) and parallel to the Y axis, through (x min , y2) and parallel to the Y axis, through (x1, y max ) and parallel to the X-axis and the line segment passing through (x2, y min ) and parallel to the X-axis. The four line segments form a rectangle. Get the lower left corner point of the rectangle (x zx ,y zx ) and the upper right corner (x ys ,y ys ), get point , marked as the center point of the breeding duck; Obtain the center points of all the ducklings of the same duckling, and make the center points of all the ducklings overlap; Draw a dividing line through the center point of the breeder duck and parallel to the Y axis, and use the dividing line to divide the breeder duck outline into two parts, left and right, marked as the left outline and the right outline; Get the smallest pixel points of the Y-axis coordinates of all left and right contours respectively, and mark them as the left foot detection pixel point and the right foot detection pixel point respectively; Get the minimum value Zx and the maximum value Zd of all detected left foot pixels on the Y axis; Get the minimum value Yx and the maximum value Yd of all detected right foot pixels on the Y axis; The difference between Zd and Zx is calculated as: Zs=Zd-Zx; where Zs is the difference between Zd and Zx; The difference between Yd and Yx is calculated as: Ys=Yd-Yx; where Ys is the difference between Yd and Yx; The absolute value of the difference between Zs and Ys is calculated as: Cz=|Zs-Ys|; where Cz is the absolute value of the difference between Zs and Ys; The normal fluctuation threshold is obtained based on the fluctuation difference between the two feet of a normal breeder duck when walking; Whether the breeder duck is lame is determined based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold.
2. The method for identifying the state of breeding ducks based on video monitoring according to claim 1, characterized in that: Acquiring multiple frames of continuous breeding duck images based on surveillance cameras includes the following sub-steps: A corridor with freely adjustable width is set up, the corridor is set with a starting point and an end point, and a surveillance camera is set above the end point of the corridor; Obtain the real-time growth month of the breeding duck and the body width function of the breeding duck, substitute the real-time growth month of the breeding duck into the body width function of the breeding duck to obtain the body width of the breeding duck, and set the body width of the breeding duck as Tks; Set the width of the corridor to: Tks+k1; k1 is the safe passage constant; Obtain the gait cycle of the breeding duck and set the gait cycle as Bt; Acquire multiple continuous frames of images of breeding ducks during the gait cycle time.
3. The method for identifying the state of breeding ducks based on video monitoring according to claim 2, characterized in that: Obtaining the duck body width function includes the following sub-steps: Obtain a first number of breeding ducks in different months, count the months of the breeding ducks and the body widths of the breeding ducks, mark the months of the breeding ducks as Nl, and mark the body widths of the breeding ducks as Tk; With the month of the breeder duck as the X-axis and the body width of the breeder duck as the Y-axis, a plane rectangular coordinate system is established, marked as the body width coordinate system; Plot the month of each group of breeder ducks and the body width of the corresponding breeder ducks into the body width coordinate system to obtain a body width scatter plot; Set the default duck body width function to: , where a, b and c are constants; The body width scatter plot was fitted with the preset breeder duck body width function to obtain the breeder duck body width function.
4. The method for identifying the state of breeding ducks based on video monitoring according to claim 3, characterized in that: Obtaining the gait cycle of the breeding duck includes the following sub-steps: Get the second number of real-time month breeders, mark the second number as P, get the number of steps of all real-time month breeders in the first time, mark it as O i ; Mark the first time as T1; Calculate the gait cycle of the breeder duck as: .
5. The method for identifying the state of breeding ducks based on video monitoring according to claim 4, characterized in that: The grayscale image processing of the breeding duck image to obtain the breeding duck grayscale image includes the following sub-steps: Get the RGB value of each pixel in the breeding duck image; Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is: H=0.299*R+0.587* G+0.114*B; H is the gray value, and R, G and B are three values in RGB value.
6. The method for identifying the state of breeding ducks based on video monitoring according to claim 5, characterized in that: The grayscale image of the breeding duck is binarized to obtain a binary image of the breeding duck, and the outline of the breeding duck is obtained based on the binary image of the breeding duck, including the following sub-steps: Divide the grayscale value of 0-255 into e equal intervals; Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency; Draw a histogram with grayscale value as X-axis and interval frequency as Y-axis, marked as grayscale histogram; Add up all interval frequencies to get the total frequency, marked as U; If there is an interval whose frequency is less than U / e, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If so, the low-frequency area is marked as the initial threshold area. Determine whether there are multiple initial threshold regions. If there is only one initial threshold region, mark the initial threshold region as the final threshold region. If there are multiple initial threshold regions, obtain the maximum value point on the X-axis of any initial threshold region, mark it as the larger split point, calculate the sum of the interval frequencies greater than the larger split point, mark it as Psd, obtain the minimum value point on the X-axis of any initial threshold region, mark it as the smaller split point, calculate the sum of the interval frequencies less than the smaller split point, mark it as Psx, calculate the absolute value of the difference between Psd and Psx and set it as the frequency difference; frequency difference = |Psd-Psx|; Obtain the frequency difference of each initial threshold region, and mark the initial threshold region corresponding to the minimum value among the multiple frequency differences as the final threshold region; The midpoint value of the abscissa of the final threshold area is set as the separation threshold; The grayscale values of pixels greater than or equal to the separation threshold are set to 255, and the grayscale values of pixels less than the separation threshold are set to 0; If a pixel with a grayscale value of 255 is adjacent to a pixel with a grayscale value of 0, the pixel with a grayscale value of 255 is marked as a breeding duck edge pixel; Count all the edge pixels of the breeding ducks and mark them as the breeding duck outlines.
7. The method for identifying the state of breeding ducks based on video monitoring according to claim 6, characterized in that: The normal fluctuation threshold is obtained based on the fluctuation difference between the two feet of a normal breeder duck when walking, including the following sub-steps: Obtain a third number of normal breeding ducks, obtain the smallest pixel points of the Y-axis coordinates of the left contours and the right contours of all normal breeding ducks, and mark them as normal left foot pixel points and normal right foot pixel points respectively; Get the minimum value Zxs and the maximum value Zds of the Y-axis of the normal left foot pixel of each breeder duck; Get the minimum value of the normal right foot pixel of each breeder duck on the Y axis as Yxs and the maximum value as Yds; The difference between Zds and Zxs is calculated as: Zss=Zds-Zxs; where Zss is the difference between Zds and Zxs; The difference between Yds and Yxs is calculated as: Yss=Yds-Yxs; where Yss is the difference between Yds and Yxs; Calculate the absolute value of all Zss and Yss differences: Czs=|Zss-Yss|; where Czs is the absolute value of the difference between Zss and Yss; Divide Czs evenly into multiple intervals, count the frequency of breeder ducks in each interval, and mark the frequency of breeder ducks in the interval; With Czs as the X-axis and the frequency of interval breeder ducks as the Y-axis, draw a difference histogram; Observe the difference histogram. If the interval breeding duck frequency is less than the distribution threshold, delete the interval breeding duck frequency, obtain the maximum value of Czs in the difference histogram, and mark the maximum value of Czs as the normal fluctuation threshold.
8. The method for identifying the state of breeding ducks based on video monitoring according to claim 7, characterized in that: Judging whether a breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold includes the following sub-steps: Determine the size of Cz and Czs. If Cz is greater than or equal to Czs, the duck is judged to be lame. If Cz is less than Czs, the duck is judged not to be lame.
9. A breeder duck status image recognition system based on video surveillance, used to implement the breeder duck status image recognition method based on video surveillance according to any one of claims 1 to 8, characterized in that: include: An image acquisition module, an image processing module, a data acquisition module, a threshold acquisition module and a lameness judgment module; The image acquisition module is used to acquire multiple frames of continuous breeding duck images based on a monitoring camera; The image processing module is used to perform grayscale image processing on the breeding duck image to obtain a breeding duck grayscale image, perform binarization processing on the breeding duck grayscale image to obtain a breeding duck binary image, and obtain the breeding duck outline based on the breeding duck binary image; The data acquisition module is used to acquire the fluctuation difference between the two feet of the breeding duck based on the outline of the breeding duck in multiple consecutive frames; The threshold value acquisition module is used to acquire a normal fluctuation threshold value based on the fluctuation difference between the two feet of a normal breeder duck when walking; The lameness judgment module is used to judge whether the breeder duck is lame based on the fluctuation difference between the two feet of the breeder duck and the normal fluctuation threshold.