A precise way to estimate the weight of pigs in the aisle

By installing a monocular camera in the pig's road, dynamically capturing the movement of the pig and performing image segmentation and morphological recognition, the image distortion problem caused by the changes in the pig posture is solved, and the accuracy and stability of the weight of the pig body weight is improved.

CN119049090BActive Publication Date: 2025-01-28SHENZHEN XIWEI SMART TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411520256.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-01-28
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

When capturing pig images in pig aisles, the image distortion problem caused by pig pose changes is ignored, resulting in a decrease in weight estimation accuracy and difficulty in identifying pig body shape characteristics, resulting in a large weight estimation error.

Method used

By installing a monocular camera above the channel, the movement of the pig dynamically, combined with the dynamic changes of the field of view and the pig, select the scope of image capture, perform image segmentation and morphological recognition, analyze the length of the pig's body, shoulder height, and motion trajectory. Generate characteristic data and calculate the weight of pig through pixel density.

Benefits of technology

It improves the accuracy of pig body weight estimation, reduces the error caused by posture changes, ensures accurate identification and stability of body shape characteristics, and optimizes feed distribution and breeding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119049090B_ABST
    Figure CN119049090B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of biological image recognition technology, and specifically to a method for accurately estimating the weight of pigs in an aisle, comprising the following steps: based on the image data of the pig captured by a monocular camera above the aisle, by calculating the field of view of the camera and the dynamic movement characteristics of the pig, selecting the image capture range, delineating the detection line in the image to calibrate the cross-line area, and calculating the movement trajectory of the pig in the image to generate initial image data. In the present invention, by dynamically capturing the movement process of the pig, the image capture range is accurately set in combination with the field of view and the dynamic changes of the pig, thereby avoiding the image distortion problem caused by a fixed viewing angle, thereby improving the accuracy of weight estimation. By means of image segmentation and morphological recognition, it is possible to effectively deal with the situation where the pig is bent or has an incomplete posture in the aisle, ensuring that the body shape characteristics of the pig can be completely and accurately identified and analyzed, and reducing the weight estimation error caused by posture changes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of biological image recognition technology, and in particular to a method for accurately estimating the weight of pigs passing through an aisle. Background Art

[0002] The field of biological image recognition technology is a field that uses image processing and pattern recognition technology to analyze and interpret image data of organisms. It includes extracting biological features from images, performing data analysis and pattern recognition to identify and classify organisms. It is widely used in medical diagnosis, agriculture, ecological monitoring, and animal population management. Through high-precision image analysis technology, accurate monitoring and evaluation of organisms can be achieved.

[0003] Among them, the accurate pig aisle weight estimation method is a method that uses biological image recognition technology to estimate the weight of pigs passing through a specific aisle. The pig's image is obtained by installing a camera or other image capture device in the aisle, and then the pig's weight is estimated by combining image recognition and processing technology. This improves breeding efficiency and optimizes feed distribution.

[0004] The existing technology relies on a camera with a fixed viewing angle to capture images of pigs in the aisle, ignoring the image distortion caused by the pigs’ posture changes during movement, resulting in reduced accuracy in weight estimation. When pigs bend in the aisle or their posture is incomplete, it is difficult to identify and accurately analyze their body shape features, resulting in large errors in weight estimation. In addition, the existing technology is prone to losing key body shape features during the image recognition stage, affecting the accurate calculation of weight. This results in unstable weight estimation data, affecting breeding efficiency and optimization of feed distribution. Summary of the invention

[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a method for accurately estimating the weight of pigs in an aisle.

[0006] In order to achieve the above purpose, the present invention adopts the following technical solution: a method for accurately estimating the weight of pigs in an aisle, comprising the following steps:

[0007] S1: Based on the image data of the pig captured by the monocular camera above the channel, the image capture range is selected by calculating the camera's field of view and the dynamic movement characteristics of the pig, the detection line in the image is delineated to calibrate the cross-line area, and the movement trajectory of the pig in the image is calculated to generate the initial image data;

[0008] S2: Based on the initial image data, identify the pigs in the cross-line area and perform image segmentation, obtain images of pigs in various forms, analyze the integrity of each pig, enhance the clarity of the image through edge sharpening and noise suppression, and generate optimized image data;

[0009] S3: Based on the optimized image data, analyzing the key feature points of the pig's body length and shoulder height, calculating the distance between the key points using the feature point coordinates, and classifying the image into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the completeness and body characteristics, to generate body shape feature data;

[0010] S4: Based on the body shape feature data, the similarities of the four types of images are analyzed, the incomplete or bent pig images are replaced with complete and upright images, the pixel density of each pig in the image is calculated, and the weight parameters are set. The weight of each pig is calculated by combining the body shape features and pixel density to generate weight estimation data.

[0011] As a further solution of the present invention, the step of acquiring the selected image capture range is specifically:

[0012] S111: Based on the image data of the pig captured by the monocular camera above the channel, the geometric parameters of the camera are calculated according to the focal length of the camera and the width of the photosensitive element, and the field of view angle of the camera is generated;

[0013] S112: Calculate the time required for the pig to pass through the field of view according to the field of view angle of the camera, and obtain time information of the pig's movement process;

[0014] S113: According to the time information of the pig's movement process and the maximum frame rate of the camera, a shooting interval is selected to establish an image capture range.

[0015] As a further solution of the present invention, the step of obtaining the motion trajectory of the pig in the calculation image is specifically as follows:

[0016] S121: Based on the image resolution of the camera monitoring screen, according to the image width and position percentage, the pixel position of the fixed detection line is selected to generate a calibration area of ​​the detection line;

[0017] S122: referring to the calibration area of ​​the detection line and the image capture range, recording the time when the pig crosses the detection line in continuous image frames, calculating its speed using the image frame rate and pixel displacement, and obtaining the pixel speed of the pig;

[0018] S123: Convert the pixel speed of the pig into the current speed, obtain its motion trajectory, and integrate the information to generate initial image data.

[0019] As a further solution of the present invention, the steps of analyzing the integrity and posture of each pig are specifically as follows:

[0020] S211: Based on the moving speed of the pig in the initial image data and the position of the detection line in the image, calculate the time point when the pig reaches the detection line to obtain the time of the detection line;

[0021] S212: When the pig reaches the detection line, the formula is used:

[0022] ;

[0023] Calculate the average pixel intensity of an image , based on the average pixel intensity of the image With the preset threshold, determine whether to perform segmentation operation and obtain the segmented image;

[0024] in, is the adjustment factor, It's time In the image frame The pixel intensity at the position, represents the position coordinates in the image, is the adjustment factor, is the ambient light compensation factor, is the total number of pixels in the image, is the normalization coefficient;

[0025] S213: Analyze the completeness of the pig in the image according to the segmented image data to obtain a morphological completeness index.

[0026] As a further solution of the present invention, the step of obtaining the clarity of the enhanced image is specifically:

[0027] S221: Based on the original image data, edge information is extracted by calculating pixel intensity changes of the image in the horizontal and vertical directions to generate edge-enhanced image data;

[0028] S222: Based on the edge-enhanced image data, optimize image noise by adjusting filtering weights to obtain optimized image data.

[0029] As a further solution of the present invention, the step of acquiring the body shape feature data is specifically as follows:

[0030] S311: From the optimized image data, locate the key feature points of shoulder height and body length, taking into account the changes of the image under various conditions, including various zoom levels or pixel densities, using the formula:

[0031] ;

[0032] Calculate the distance between two points and get the distance data between the two points ;

[0033] in, and is the coordinate of the shoulder height point, and are the coordinates of the body length point, is the factor that adjusts the image scaling, is the factor that adjusts the image scaling, is the pixel density adjustment factor;

[0034] S312: Calculate the spinal curvature of the pig in the image based on the distance data between the two points, perform image classification operations in combination with the morphological integrity index, and generate body feature data.

[0035] As a further solution of the present invention, the step of calculating the pixel density of each pig in the image is specifically as follows:

[0036] S411: Based on the body shape feature data and the degree of spinal curvature, the formula is used:

[0037]

[0038] Calculate the similarity between the two pigs in the image and get the image and images The similarity score between ;

[0039] in, and is an image and The completeness index, and is an image and 'The curvature, and is the adjustment factor;

[0040] S412: After determining whether to replace the incomplete or bent pig image with a complete and upright image based on the similarity score, the pixel density of each pig in the selected image is calculated to obtain weight density data.

[0041] As a further solution of the present invention, the steps of calculating the weight of each pig are specifically as follows:

[0042] S421: Calculate the total weight of all pigs according to the morphological integrity index, the total number of pixels in the image and the weight density data to obtain total weight data;

[0043] S422: Calculate the average weight of the pigs based on the total weight data to generate weight estimation data.

[0044] A precise pig aisle weight estimation system, the precise pig aisle weight estimation system is used to implement the above-mentioned precise pig aisle weight estimation method, the system comprises:

[0045] The image capture and positioning module uses the monocular camera above to capture the pig image, determines the capture range according to the field of view, calibrates the detection line and the crossing line area in the image, calculates the pig's movement trajectory, and generates initial image data;

[0046] The image optimization processing module performs image segmentation based on the initial image data, obtains pig images of various forms, performs edge sharpening and noise suppression on the images, and generates optimized image data;

[0047] The key morphological feature module analyzes the key feature points of the pig's body length and shoulder height based on the optimized image data, calculates the distance between the key points, and classifies the image into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the body integrity and morphology, thereby generating body shape feature data;

[0048] The image replacement and similarity analysis module performs a replacement operation on the incomplete or curved image based on the body shape feature data, selects a complete and upright image, analyzes the image similarity, and generates replaced image data;

[0049] The weight estimation calculation module calculates the pixel density of each pig based on the replaced image data, sets weight parameters, and estimates the weight of each pig by combining the body shape characteristics and the pixel density to generate weight estimation data.

[0050] Compared with the prior art, the advantages and positive effects of the present invention are:

[0051] In the present invention, the movement process of the pig is captured dynamically, and the image capture range is accurately set in combination with the field of view and the dynamic changes of the pig, thereby avoiding the image distortion problem caused by the fixed viewing angle, thereby improving the accuracy of weight estimation. Through image segmentation and morphological recognition, it can effectively deal with the situation where the pig is bent in the aisle or the posture is incomplete, ensuring that the body shape characteristics of the pig can be completely and accurately identified and analyzed, and reducing the weight estimation error caused by posture changes. At the same time, the optimized image data can ensure that the key body shape characteristics of the pig can be clearly captured, improving the accuracy and stability of weight calculation. In addition, by replacing the incomplete or bent image and using the complete and upright pig image as the calculation basis, the problem of unstable weight estimation data caused by changes in the pig's posture is eliminated, and the accuracy of feed distribution and the optimization of breeding efficiency are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a schematic diagram of the main steps of the present invention;

[0053] Figure 2 A flow chart of the acquisition steps for selecting an image capture range for the present invention;

[0054] Figure 3A flow chart of the steps for obtaining the motion trajectory of a pig in an image according to the present invention;

[0055] Figure 4 A flowchart of the steps for analyzing the integrity and posture of each pig in the present invention;

[0056] Figure 5 A flow chart of the acquisition steps for enhancing the clarity of an image according to the present invention;

[0057] Figure 6 is a flow chart of the steps of obtaining body shape feature data of the present invention;

[0058] Figure 7 A flow chart of the acquisition steps for calculating the pixel density of each pig in the image according to the present invention;

[0059] Figure 8 The steps for obtaining the weight of each pig in the present invention are specifically shown as a flow chart. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0061] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, "multiple" means two or more, unless otherwise clearly and specifically defined.

[0062] See also Figure 1 The present invention provides a technical solution: a method for accurately estimating the weight of pigs in an aisle, comprising the following steps:

[0063] S1: Based on the image data of the pig captured by the monocular camera above the channel, the image capture range is selected by calculating the camera's field of view and the dynamic movement characteristics of the pig, the detection line in the image is delineated to calibrate the cross-line area, and the movement trajectory of the pig in the image is calculated to generate the initial image data;

[0064] S2: Based on the initial image data, identify the pigs in the crossing area and perform image segmentation, obtain images of pigs in various forms, analyze the integrity of each pig, enhance the clarity of the image through edge sharpening and noise suppression, and generate optimized image data;

[0065] S3: Based on the optimized image data, the key feature points of the pig's body length and shoulder height are analyzed, the distance between the key points is calculated using the feature point coordinates, and the image is classified into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the completeness and body characteristics to generate body shape feature data;

[0066] S4: Based on the body shape feature data, the similarity of the four types of images is analyzed, the images of incomplete or bent pigs are replaced with complete and upright images, the pixel density of each pig in the image is calculated, and the weight parameter is set. The weight of each pig is calculated by combining the body shape features and pixel density to generate weight estimation data;

[0067] The initial image data includes the captured image frame sequence, the calibrated coordinates of the crossing line area and the time series data of the pig's movement. The optimized image data includes the image segmentation results, the clarity information of the image edges and the morphological feature data of each pig. The body feature data includes the body length data, the shoulder height data, the body classification label and the coordinate positions of the key feature points. The weight estimation data includes the estimated weight of each pig, the pixel density after image replacement and the correlation data between body shape characteristics and weight.

[0068] See also Figure 2 , the steps for obtaining the selected image capture range are as follows:

[0069] S111: Based on the image data of the pig captured by the monocular camera above the channel, the geometric parameters of the camera are calculated according to the focal length of the camera and the width of the photosensitive element to obtain the field of view angle of the camera;

[0070] To calculate the geometric parameters of the camera, the formula is used:

[0071] ;

[0072] in, is the camera's field of view, which represents the angle of the visual range that the camera can cover. is the width of the photosensitive element, indicating the size of the camera's photosensitive component. It is the focal length of the camera, which refers to the distance from the camera lens to the photosensitive element and is used to determine the camera's field of view. is the inverse tangent function, which is used to convert the geometric parameters of the camera into the field of view angle;

[0073] Setting parameters 35mm (full-frame camera standard), 50mm;

[0074] ;

[0075] The calculation results show that when the camera uses a 50mm focal length and a 35mm wide sensor, the field of view is approximately 38.58 degrees, which means that the camera can cover the scene within this angle range.

[0076] S112: Calculate the time required for the pig to pass through the field of view according to the field of view angle of the camera, and obtain the time information of the pig's movement process;

[0077] To calculate the time required for the pig to pass through the field of view, the formula is used:

[0078] ;

[0079] in, is the minimum time required for a pig to cross the camera's field of view, is the speed of pig movement, obtained through monitoring and data analysis of pigs walking in the aisle. is the tangent function, which is used to calculate the actual width of the field of view based on the field of view angle;

[0080] Based on actual conditions, the walking speed of the pigs was set to 0.6 m / s;

[0081] ;

[0082] This time reflects the time it takes for the pig to cross the camera's field of view when walking at a speed of 0.6 m / s. .

[0083] S113: selecting a shooting interval and establishing an image capture range according to the time information of the pig's movement process and the maximum frame rate of the camera;

[0084] To calculate the image capture range, the formula is used:

[0085] ;

[0086] in, is the maximum frame rate of the camera, which refers to the maximum number of frames the camera can capture per second. It is obtained through the camera's specification information. is a minimum function, which is used to select the minimum value between the actual shooting interval and the maximum frame rate of the camera to ensure that no key dynamics are missed;

[0087] If the camera's maximum frame rate 30 frames / second, take the smaller value, the corresponding shooting interval Determined by the following formula:

[0088] ;

[0089] Will Frames / second is entered into the formula for calculation:

[0090] ;

[0091] This means that the camera can capture one frame every 0.0333 seconds, ensuring that at least 5 frames can be captured within 166.7 milliseconds when the pig passes through the field of view, effectively capturing the pig's movements.

[0092] See also Figure 3 , the specific steps for obtaining the motion trajectory of the pig in the calculation image are:

[0093] S121: Based on the image resolution of the camera monitoring screen, according to the image width and position percentage, the pixel position of the fixed detection line is selected to generate a calibration area of ​​the detection line;

[0094] For the pixel position of the selected fixed detection line, the formula is used:

[0095]

[0096] in, is the pixel position of the detection line in the image is the position of the detection line relative to the image width in percentage (0 to 100), determined by observing the image, is the total width of the image, obtained from the camera resolution parameter;

[0097] Obtain the total image width from the camera or image processing system If the camera resolution is 1920 pixels wide, Pixels. Set the position of the detection line in the image to 50% of the image width, that is, .

[0098] Calculated according to the formula:

[0099] ;

[0100] The results show that the detection line is located in the center of the image.

[0101] S122: referring to the calibration area of ​​the detection line and the image capture range, recording the time when the pig crosses the detection line in the continuous image frames, calculating its speed using the image frame rate and pixel displacement, and obtaining the pixel speed of the pig;

[0102] For calculating its speed using image frame rate and pixel displacement, the formula is used;

[0103] ;

[0104] in, is the position difference of the pig in two consecutive frames, which is obtained by image processing technology. The calculation formula is: ,here and Represents the pig's movement along the The pixel position in the direction, is the pixel speed of the pig during movement;

[0105] Set the camera frame rate to 30 frames per second. seconds. If the pig moves from pixel position 960 to pixel position 980 in two consecutive frames, then Pixel.

[0106] Use the formula to calculate the pixel speed of the pig while it is moving:

[0107] ;

[0108] The results showed that the pigs crossed the detection line at a speed of approximately 600 pixels per second.

[0109] S123: converting the pixel speed of the pig during movement into the current movement speed, obtaining its movement trajectory, and integrating the information to generate initial image data;

[0110] To convert the pig's pixel speed to its current speed, the formula is used:

[0111] ;

[0112] in, is the current speed of the pig, is the camera's field of view width, obtained from the camera's technical specifications, is the image width, which is determined by the image resolution parameter;

[0113] If the camera field of view width The image width is 2 meters. is 1920 pixels, then:

[0114] ;

[0115] The results showed that the pigs moved at a speed of about 0.625 meters per second under the current conditions, providing important data about their movement status.

[0116] See also Figure 4 ,The steps to analyze the integrity and posture of each pig are as follows:

[0117] S211: Based on the moving speed of the pig in the initial image data and the position of the detection line in the image, the time point when the pig reaches the detection line is calculated to obtain the time of the detection line;

[0118] To calculate the time point when the pig reaches the detection line, the formula is used:

[0119] ;

[0120] in, is the pixel position of the detection line in the image, determined by image analysis software, is the time when the pigs arrive at the testing line;

[0121] Setting parameters is 960 pixels, =0.625 m / s. Based on the experimental setting or the measurement standard of the equipment, if 1 pixel is 0.001 m, the time is calculated according to the position of the detection line and the speed of the pig, and the time when the pig reaches the detection line is obtained. :

[0122] ;

[0123] The results showed that the pig would reach the detection line in approximately 1.54 seconds.

[0124] S212: When the pig reaches the detection line, the image frame at that time point is processed, the average pixel intensity of the image is calculated, and according to the average pixel intensity of the image and a preset threshold, it is determined whether to perform a segmentation operation, and the segmented image is obtained;

[0125] To calculate the average pixel intensity of an image, the formula is used:

[0126] ;

[0127] in, is the adjustment coefficient, obtained through experimental data optimization, It's time In the image frame The pixel intensity at the position is read by image processing software. Represents the horizontal and vertical coordinate indexes of the image data, is the adjustment factor, and the ambient light compensation factor Use in combination, is the ambient light compensation factor, which is analyzed based on the ambient light conditions of the scene and is used to adjust the brightness effect. is the total number of pixels in the image, obtained from the image metadata, is the normalization coefficient used to balance the effect of light compensation and is determined based on experimental data;

[0128] Setting parameters is 0.8, is 0.2, 50 means slight ambient light effect. =10, balance the effect of light compensation, The total number of pixels is 10000, Set to , the average pixel intensity of the image frame is 120.

[0129] Calculate the average pixel intensity :

[0130] ;

[0131] Segmentation Threshold is set to 90 based on past experience to distinguish objects from background, because in most cases the image area above this threshold is sufficient to show clear object outlines. If it is greater than 90, a split is performed.

[0132] S213: Analyze the integrity of the pig in the image according to the segmented image data to obtain a morphological integrity index;

[0133] To analyze the completeness of the pig in the picture, the formula is used:

[0134] ;

[0135] in, is the area of ​​the pig in the segmented image, which is analyzed by image processing technology. is the perimeter of the pig boundary in the segmented image, measured by image analysis software It is an indicator of the morphological integrity of the pig;

[0136] Setting parameters The area is 200 square pixels. The border perimeter is 50 pixels.

[0137] Using the above data, calculate the pig's morphological integrity index :

[0138] ;

[0139] Morphological integrity index A value of 4 indicates a high degree of morphological integrity. In general, a high morphological integrity index (e.g., more than 3) indicates that the image has a high area-to-perimeter ratio, which means that the image has simple boundaries and large areas, and the image boundaries appear neater than more complex or fragmented shapes, indicating a more stable posture.

[0140] See also Figure 5 , the steps for obtaining the enhanced image clarity are as follows:

[0141] S221: Based on the original image data, edge information is extracted by calculating pixel intensity changes of the image in the horizontal and vertical directions to generate edge-enhanced image data;

[0142] To calculate the pixel intensity changes of the image in the horizontal and vertical directions, the formula is used:

[0143] ;

[0144] in, is the gradient strength of the image, which is used to indicate the clarity of the image edge. The image is in the horizontal direction The pixel intensity change rate is The image is in the vertical direction The pixel intensity change rate is is the original image data, are the horizontal and vertical coordinate indices of the image data;

[0145] Through actual image data monitoring, the grayscale value of a pixel changes from 100 to 150 in the horizontal direction and from 100 to 130 in the vertical direction, then:

[0146] ;

[0147] ;

[0148] Substituting into the formula we get:

[0149] ;

[0150] The results show that the image edge sharpening result at this pixel point is a gradient intensity of about 58.31, indicating the clarity of the edge.

[0151] S222: Based on the edge-enhanced image data, the image noise is optimized by adjusting the filtering weight to obtain optimized image data;

[0152] To adjust the filter weights and optimize image noise, the formula is used:

[0153] ;

[0154] in, It is the weight adjusted according to the edge strength to reduce the impact of noise while maintaining the clarity of the edge part. The calculation method is: , Represents the value of each pixel in the image, is the image data after noise reduction processing, is a coefficient that adjusts the strength of edge preservation, determined based on statistical analysis;

[0155] Setting parameters , is 0.05, ;

[0156] Calculating weights :

[0157] ;

[0158] Consider a 3x3 pixel block, where each pixel is weighted the same way, and then the above formula is applied to calculate the weighted average to determine :

[0159] If the average value of the surrounding pixels is also 120, then:

[0160] ;

[0161] It means that after noise suppression, the processing result of the pixel is maintained at 120, which shows the effectiveness of noise suppression and retains the edge information of the image.

[0162] See also Figure 6 , the specific steps for obtaining body shape feature data are:

[0163] S311: From the optimized image data, locate the key feature points of shoulder height and body length, considering the changes of the image under various conditions, including various zoom levels or pixel densities, using the formula:

[0164] ;

[0165] Calculate the distance between two points and get the distance data between the two points ;

[0166] in, and is the coordinate of the shoulder height point, and are the coordinates of the body length point, It is the factor that adjusts the image scaling to adapt to the changes in different image resolutions. It is obtained based on the ratio analysis of the actual image resolution and the standard resolution. It is the factor that adjusts the image scaling to adapt to different vertical sizes, and is derived based on the image's vertical resolution ratio analysis. is the pixel density adjustment factor, accounting for differences in pixel sizes on different devices;

[0167] Setting parameters Pixels, Pixels, Pixel by pixel, Pixels, , , ;

[0168] Horizontal distance adjustment:

[0169] Pixels;

[0170] Vertical distance adjustment:

[0171] Pixels;

[0172] Compute the distance between two points:

[0173] ;

[0174] The calculated adjusted distance between the two points was used to quantify specific dimensions of pig body shape, including body length and withers height.

[0175] S312: Calculate the spinal curvature of the pig in the image based on the distance data between the two points, perform image classification operations in combination with the morphological integrity index, and generate body shape feature data;

[0176] To calculate the curvature of the pig spine, the image classification operation was performed in combination with the morphological integrity index, using the formula:

[0177] ;

[0178] in, is the curvature, which indicates the curvature of the spine. It is the angle change on the spine line. It is a tiny distance along the spine line;

[0179] According to completeness and curvature The calculation results classify the pigs in the image into the following four types:

[0180] Complete and upright: If The value is high (close to 4 or higher) and , pigs were classified as complete and erect.

[0181] Complete but bent: If Higher value and Although the pig is intact, its body is bent.

[0182] Incomplete and upright: If The value is low (much lower than 4) and , the pig may be incomplete but upright.

[0183] Incomplete and curved: If The value is low and , the pigs are incomplete and bent.

[0184] Setting parameters It is calculated by analyzing the angle difference between two points on the spine. Pixels are the actual pixel distance between two points on the spine line.

[0185] Will Convert from degrees to radians, radian;

[0186] = radian;

[0187] Curvature calculate:

[0188] radians / pixel;

[0189] use (indicating high integrity) and calculated (slightly bent), which would classify the pig as intact but bent.

[0190] See also Figure 7 , the steps to calculate the pixel density of each pig in the image are as follows:

[0191] S411: Based on the body shape data and the degree of spinal curvature, the formula is used:

[0192] ;

[0193] Calculate the similarity between the two pigs in the image and get the image and images The similarity score between ;

[0194] in, and is an image and These data are automatically extracted from the image of each pig by image processing software and are evaluated based on the clarity and completeness of the contours. and is an image and The curvature of the pig spine is calculated by image analysis software and determined based on the visible curvature of the pig spine. and is the adjustment factor, and They represent the influence weights of integrity and curvature in similarity calculation, which are determined according to previous experimental data or similar studies to ensure the sensitivity and accuracy of the calculation results;

[0195] Set the integrity index of the two pigs , , curvature , , and the weight coefficient , ;

[0196] Impact of completeness differences:

[0197] ;

[0198] Effect of curvature differences:

[0199] ;

[0200] Similarity calculation:

[0201] ;

[0202] result It means that the two pigs have a high degree of similarity in the image. If the threshold is set to 0.5, it means that the two pigs are similar enough and the images can be replaced as needed.

[0203] S412: after determining whether to replace the incomplete or bent pig image with a complete and upright image based on the similarity score, the pixel density of each pig in the selected image is calculated to obtain weight density data;

[0204] To calculate the pixel density of each pig in the image, the formula is used:

[0205] ;

[0206] in, is the average weight density per pixel, is the estimated total weight of the pig, based on known standard weights or previous measurements, is the total number of pixels in the selected image, obtained directly from the image file's metadata;

[0207] If a pig is known to weigh 200 kg, the total number of pixels in the image is 2,000,000 pixels.

[0208] Convert weight from kilograms to grams. ;

[0209] Calculate the average weight density per pixel using the total weight and total number of pixels:

[0210] ;

[0211] Calculation results This indicates that each pixel represents an average of 0.1 grams of weight. This density parameter will be used to further estimate the weight of pigs in other images, especially after image replacement, to ensure the consistency and accuracy of the estimated weight.

[0212] See also Figure 8 , the steps to calculate the weight of each pig are as follows:

[0213] S421: Calculate the total weight of all pigs according to the morphological integrity index, the total number of pixels in the image and the weight density data to obtain the total weight data;

[0214] For calculation of total weight of all pigs, the formula was used;

[0215] ;

[0216] in, is the total weight of the pig, is the average weight density per pixel, obtained by comparing images with known weights, It is The total number of pixels of the pig in the image, read directly from the image file metadata, It is The morphological integrity index of each pig is calculated by image analysis software. is the total number of pigs, is the adjustment factor used to adjust the difference between the estimated weight and the actual observed value;

[0217] Suppose there are 3 pigs, and the number of pixels in each pig's image is Pixels, body factor Both are 4, g / pixel and set the adjustment factor

[0218] ;

[0219] The results showed that the total weight of the three pigs was .

[0220] S422: Calculate the average weight of the pigs based on the total weight data and generate weight estimation data;

[0221] For calculation of average weight of pigs, the formula is used:

[0222] ;

[0223] in, is the average weight of a pig;

[0224] The total weight to be obtained and the total number of pigs , estimate the average weight of pigs :

[0225] ;

[0226] The results showed that the estimated weight of each pig was .

[0227] A precise pig aisle weight estimation system, the precise pig aisle weight estimation system is used to implement the above-mentioned precise pig aisle weight estimation method, the system comprises:

[0228] The image capture and positioning module uses the monocular camera above to capture the pig image, determines the capture range according to the field of view, calibrates the detection line and the crossing line area in the image, calculates the pig's movement trajectory, and generates initial image data;

[0229] The image optimization processing module performs image segmentation based on the initial image data, obtains pig images of various forms, performs edge sharpening and noise suppression on the images, and generates optimized image data;

[0230] The key morphological feature module analyzes the key feature points of the pig's body length and shoulder height based on the optimized image data, calculates the distance between the key points, and classifies the image into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the body integrity and morphology, generating body shape feature data;

[0231] The image replacement and similarity analysis module performs a replacement operation on the incomplete or curved image based on the body shape feature data, selects a complete and upright image, analyzes the image similarity, and generates the replaced image data;

[0232] The weight estimation calculation module calculates the pixel density of each pig based on the replaced image data, sets weight parameters, combines body shape characteristics with pixel density, estimates the weight of each pig, and generates weight estimation data.

[0233] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A method for accurately estimating the weight of pigs in an aisle, characterized in that: The following steps are involved: Based on the image data of the pig captured by the monocular camera above the channel, the image capture range is selected by calculating the camera's field of view and the dynamic movement characteristics of the pig, the detection line in the image is delineated to calibrate the cross-line area, and the movement trajectory of the pig in the image is calculated to generate the initial image data; The steps of obtaining the selected image capture range are specifically as follows: Based on the image data of the pig captured by the monocular camera above the channel, the geometric parameters of the camera are calculated according to the focal length of the camera and the width of the photosensitive element to generate the camera's field of view; According to the field of view angle of the camera, the time required for the pig to pass through the field of view is calculated to obtain the time information of the pig's movement process; According to the time information of the pig's movement process and the maximum frame rate of the camera, a shooting interval is selected to establish an image capture range; The steps for obtaining the motion trajectory of the pig in the calculation image are specifically as follows: Based on the image resolution of the camera monitoring screen, the pixel position of the fixed detection line is selected according to the image width and position percentage, and the calibration area of ​​the detection line is generated; Referring to the calibration area of ​​the detection line and the image capture range, the time when the pig crosses the detection line in continuous image frames is recorded, and its speed is calculated using the image frame rate and pixel displacement to obtain the pixel speed of the pig; Convert the pixel speed of the pig into the current speed, obtain its motion trajectory, and integrate the information to generate initial image data; Based on the initial image data, the pigs in the crossing area are identified and image segmentation is performed to obtain images of pigs in various forms, the integrity of each pig is analyzed, the clarity of the image is enhanced by edge sharpening and noise suppression, and optimized image data is generated; The steps for analyzing the integrity of each pig are as follows: Based on the moving speed of the pig in the initial image data and the position of the detection line in the image, the time point when the pig reaches the detection line is calculated to obtain the time of the detection line; When the pig reaches the detection line, the formula is used: Calculate the average pixel intensity μ of the image, determine whether to perform a segmentation operation based on the average pixel intensity μ of the image and a preset threshold, and obtain the segmented image; Among them, α1 is the adjustment coefficient, f a,b (t′) is the pixel intensity at position (a, b) in the image frame at time t′, a, b represent the position coordinates in the image, β1 is the adjustment coefficient, K1 is the ambient light compensation factor, N is the total number of pixels in the image, and γ1 is the normalization coefficient; According to the segmented image data, the integrity of the pig in the picture is analyzed to obtain the morphological integrity index; Based on the optimized image data, analyzing the key feature points of the pig's body length and shoulder height, calculating the distance between the key points using the feature point coordinates, and classifying the images into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the completeness and body characteristics, to generate body shape feature data; Based on the body feature data, the similarities of the four types of images are analyzed, the incomplete or bent pig images are replaced with complete and upright images, the pixel density of each pig in the image is calculated, and the weight parameters are set. The body feature and pixel density are combined to calculate the weight of each pig and generate weight estimation data.

2. The accurate pig aisle weight estimation method according to claim 1 is characterized in that: The steps for obtaining the definition of the enhanced image are specifically as follows: Based on the original image data, edge information is extracted by calculating the pixel intensity changes in the horizontal and vertical directions of the image to generate edge-enhanced image data; Based on the edge-enhanced image data, the image noise is optimized by adjusting the filter weight to obtain optimized image data.

3. The accurate pig aisle weight estimation method according to claim 2 is characterized in that: The steps for obtaining the body shape feature data are specifically as follows: From the optimized image data, the key feature points of shoulder height and body length are located, taking into account the changes of the image under various conditions, including various zoom levels or pixel densities, using the formula: Calculate the distance between two points and obtain the distance data d between the two points; Among them, x1 and y1 are the coordinates of the shoulder height point, x2 and y2 are the coordinates of the body length point, α2 is the factor for adjusting the image scale, β3 is the factor for adjusting the image scale, and γ2 is the pixel density adjustment factor; According to the distance data between the two points, the spinal curvature of the pig in the image is calculated, and the image classification operation is performed in combination with the morphological integrity index to generate body feature data.

4. The accurate pig aisle weight estimation method according to claim 3 is characterized in that: The steps for calculating the pixel density of each pig in the image are specifically as follows: According to the body shape characteristic data and the curvature of the spine, the formula is used: Calculate the similarity between the two pigs in the image and get the similarity score S between image a and image b a′b′ ; Among them, A a′ and A b′ is the completeness index of images a′ and b′, ​​κ a′ and κ b′ is the curvature of images a′ and b′, ​​a2 and b4 are adjustment coefficients; After determining whether to replace the incomplete or bent pig image with a complete and upright image based on the similarity score, the pixel density of each pig in the selected image is calculated to obtain the weight density data.

5. The accurate pig aisle weight estimation method according to claim 4 is characterized in that: The steps for calculating the weight of each pig are specifically as follows: Calculate the total weight of all pigs according to the morphological integrity index, the total number of pixels in the image and the weight density data to obtain the total weight data; Based on the total body weight data, the average weight of the pigs was calculated to generate weight estimation data.

6. An accurate pig aisle weight estimation system, characterized in that: According to any one of claims 1 to 5, the accurate pig aisle weight estimation system comprises: The image capture and positioning module uses the monocular camera above to capture the pig image, determines the capture range according to the field of view, calibrates the detection line and the crossing line area in the image, calculates the pig's movement trajectory, and generates initial image data; The image optimization processing module performs image segmentation based on the initial image data, obtains pig images of various forms, performs edge sharpening and noise suppression on the images, and generates optimized image data; The key morphological feature module analyzes the key feature points of the pig's body length and shoulder height based on the optimized image data, calculates the distance between the key points, and classifies the image into complete and upright, complete but bent, incomplete and upright, incomplete and bent according to the body integrity and morphology, thereby generating body shape feature data; The image replacement and similarity analysis module performs a replacement operation on the incomplete or curved image based on the body shape feature data, selects a complete and upright image, analyzes the image similarity, and generates replaced image data; The weight estimation calculation module calculates the pixel density of each pig based on the replaced image data, sets weight parameters, and estimates the weight of each pig by combining the body shape characteristics and the pixel density to generate weight estimation data.

Citation Information

Patent Citations

  • Pig weight measurement method and system based on images

    CN108961269A

  • Group-fed pig identity recognition method based on feature fusion

    CN114519864A